Stunt programming. Modern C++ is not about that.

User Manual

Contents

Due to a popular demand here is a short user manual on how to use "dbj  defval" Option 2.2 and Option 3.

First please recall the top of this article. We are using GDI+ to add some dose of reality to these usage examples.

How to use Option 2.2

Declared as a “stunt” but of course, perfectly usable.

You declare and define inside some namespace the global instances; after which callers from possible separate threads can use. Or change.

How to use Option 3

note: c++ anonymous name spaces make variables inside them to have internal linkage. To make sure things are not multiplied and instances are unique I very rarely use them. Please do use named name space’s around these examples.

You declare and define  dbj::holder<> instances as (c++17) inline globals. Then every caller from some thread uses them.  Please keep in mind calls above could be scattered across few threads, but that would make code longer and will obfuscate the usage pattern.

 

The C++ Tool
The C++ Tool