D-Programming-Language/phobos — pull request #1603 by monarchdodra (2013-09-27 12:56:03+00:00)
Title: fix swap to check full mutability

This addresses the issue that swap can currently modify const members of structs. This is obviously wrong behavior.

One the one hand, it's wrong behavior, so should be fixed. On the other end, there is no easy way to cast away "member constness", so there is no way for a user to say "I know what I'm doing, do it anyways".

Furthermore, i really don't like the idea of a trusted function doing something so wrong.

Maybe a good "workaround" would be for swap to accept structs with const members, but to not provided safety in such cases? It's still wrong, but at least, it can only happen in @system code?

Yeah, a bit of input would be welcome.