When does gender matter? Gender segregation in the professions of medicine, teaching and law