Red Code/Green Code – Generalizing Const

Speaker: Scott Meyers


C++ compilers allow non-const code to call const code, but going the other way requires a cast. In this talk, Scott describes an approach he’s been pursuing to generalize this notion to arbitrary criteria. For example, thread-safe code should only call other thread-safe code (unless you explicitly permit it on a per-call basis). Ditto for exception-safe code, code not “contaminated” by some open source license, or any other constraint you choose. The approach is based on template metaprogramming (TMP), and the implementation uses the Boost metaprogramming library (Boost.MPL), so constraint violations are, wherever possible, detected during compilation.