C++ does not have native support for fields with getters and setters, as many languages now do. That's because Real Programmers don't use properties, right?
Right. But if they did, and they wanted to almost break the compiler, this is how they would implement a library solution to the problem.
Our journey will take us through reinterpret-casting pointers (meh), C-style casting the literal zero (oh man), perfect forwarding of const-volatile qualifiers (!) and the innards of partially defined types (meltdown).
In short, if you wanted to know everything about how to do things that shouldn't work, but do (spot the undefined behavior!), see you there.
YOU MAY ALSO LIKE:
A Proper Property
Gašper has been trying to have the compiler prove his code since 2008, and it's been going better of late. He has written code for the web, backends, and research tools, for UC Berkeley, A9.com, and currently Citadel. He has corrected proofs in "From Mathematics to Generic Programming", and frequently attends C++ conferences.