Sorry about necrobumping, but I've ignored this thread previously as the
subject line didn't make it obvious this thread was of my interest.
2015-11-24 17:20 GMT-03:00 Andrey Semashev
I don't think for is a good idea, given that the
same effect can be achieved in pure C++.
You mean creating a class template with a single dummy template argument and a static data member just so that you can define a global variable in a header w/o linker errors?
Slightly better:
template< typename T, typename Tag = void > struct singleton { static T instance; }; template< typename T, typename Tag > T singleton< T, Tag >::instance;
I was looking for something similar to BOOST_OVERRIDABLE_SYMBOL as I want my library header only and Boost.System requires the category to be a single static object and it'll even use address comparison to test if the categories are the same: https://github.com/boostorg/system/blob/388b3497af4b205ff7e8c67ea306f57eea62... Is it guaranteed the above code will return the same object even if this code was included in different libraries used by the same program? -- VinÃcius dos Santos Oliveira https://vinipsmaker.github.io/