I've created a template class which triggers a runtime text output whenever an instantiation of it occurs:
template<typename T>
struct verbose {
verbose()
{
std::cout << "Instantation occured!" << std::endl;
}
};
template<typename T>
struct base
{
inline static verbose<T> v;
};
When I force to create instantiation, it shows an output:
template struct base<int>;
//output: Instantation occured!
On the other hand, when I use it with a CRTP pattern, it seems that instantiation does not occur:
class test : public base<test>
{
};
Is this behavior OK with the ISO standard? Can I somehow force to make instantiation, without requiring users of my template class (base) to write additional code? For me, the important thing is the side effect of the static variable constructor.