As it does not solve anything, it is, by definition, not a solution.
Can I just say something? The whole "dangerous pervert" angle is a red herring, and we have to dispense with it. Even the hypothetical you've presented - "could there be... probably" - is ridiculous. Not one person is going to attempt to pass themselves off as trans to gain access to other people in a restroom. It requires a lot of effort to present, and presentation will make you visible or notable, either because you do not pass, or because you perform femininity/masculinity to a prototypical level to pass. There are probably hundreds of ways to sneak a peek, and not one of them is going to be more difficult, nor expose the hypothetical pervert to greater risk of discovery and/or violence.
The whole legal push against transfolk is not about public safety. It won't improve the safety of any restroom occupant. It does not address the incidents that do occur in restrooms. All it seeks to do, and all it does in real terms, is make a subset of the population more vulnerable.