I used to be a high school teacher and I am a mom... so I see both sides of this problem. Honestly, I think that the best solution is just to have short transition periods, and if someone has to go then they have to ask. The place I worked kids had about a minute between classes, but sometimes it took them 20 seconds to get to my room from another and they just put their stuff down and said, hey, I'm here, just going to the bathroom. I never had a problem with that, even if they didn't get back before the late buzzer. It was an all-girls school, so we didn't deal with sex in the bathroom (that I know of)... but we did deal with drugs and drinking. It can be a problem, but I think there are other ways to deal with it besides making everyone wait till lunch time.
As a mom of a brand new Kindergartener, I sure as heck hope they don't make my son wait, but he's only 5. 5, 6 , 7 ... all of those ages are a little different than 15. Yet, I think we have to give our children some credit. How many of us have been on the highway when our five year olds, or three year olds, have said, mom, I have to pee? Ok, well, great, the next exit is 10 minutes away, your going to have to hold it, just for a minute. I know kids can't concentrate if they really, really have to go to the bathroom, but by the same token its not always easy to have one kid after another constantly leaving the room. Honestly, the best solution is to let them go between classes if they need to and then, if they really have to go during class, they need to be able to, just not make a habit of it. For younger grades, bathroom breaks need to be built in.