Get the latest tech news

Needlessly Public


When working on a legacy codebase that has leading-edge C++ constructs, but also deeply legacy design decisions, sometimes there’s nifty ways to use the one against the other.

Legacy codebases will also have lots of missing const, which is something clang-tidy can help with, and often use int where std::size_t is meant – but those are critiques for the function consumer(), not the Example class. But it works, in the sense that consumers have no code change, read-only behavior is enforced, and only the methods of class Example can write to the hidden data. For my particular legacy codebase, I ended up using the pointer approach to verify that all (but one) access was read-only, and then rolled it back because the Hidden class example didn’t work well with others.

Get the Android app

Or read this on Hacker News