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:
- Lightbend Scala Language - Professional (in London on 17th - 18th September 2018)
- CloudNative London 2018 (in London on 26th - 28th September 2018)
- Well-Typed's Guide to the Haskell Type System (in London on 10th October 2018)
- Well-Typed's Guide to Haskell Performance and Optimization (in London on 15th - 16th October 2018)
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.