For the record, the UK Equality Act 2010 is very explicit here:
Schedule 3, section 27 [Single sex services] subsection 4:
(4) The condition is that—
(a) a joint service for persons of both sexes would be less effective, and
(b) the extent to which the service is required by persons of each sex makes it not reasonably practicable to provide separate services.
And section 28 [Gender reassignment]:
28(1) A person does not contravene section 29, so far as relating to gender reassignment discrimination, only because of anything done in relation to a matter within sub-paragraph (2) if the conduct in question is a proportionate means of achieving a legitimate aim.
(2)The matters are—
(a) the provision of separate services for persons of each sex;
(b) the provision of separate services differently for persons of each sex;
(c) the provision of a service only to persons of one sex.
See also the Explanatory Notes with regard to lawful exclusion of the opposite sex, including people protected by the characteristic of Gender reassignment [see paras 729 -740]:
www.legislation.gov.uk/ukpga/2010/15/notes/division/3/16/20/7