I recently ended up building a configuration system for a piece of C++ software I’m maintaining. One
feature I wanted was: I want to just create new configuration items at arbitrary locations in my
code without “registering” them somewhere centrally. The config system should just “pick them up” on
startup.
One prominent example of a library using a similar functionality is Google Test, Google’s testing framework. In Google Test, you can just write something like
1TEST(TestSuiteName, TestName) {
2 ... test body ...
3}
somewhere is your code, and when Google Test’s main function runs, it picks up on your test and
runs it.
How does one achieve that?