D
Derek
Here is a simple template with a non-const static data member:
template <typename T>
class Foo
{
public:
static int bar;
};
template <typename T> int Foo<T>::bar = 42;
What I want to know is how the compiler/linker guarantees there
will only be one Foo<T>::bar for each possible T? I assume the
compiler generates storage for Foo<T>::bar in every translation
unit that instantiates Foo<T> and tasks the linker with stripping
any duplicates?
template <typename T>
class Foo
{
public:
static int bar;
};
template <typename T> int Foo<T>::bar = 42;
What I want to know is how the compiler/linker guarantees there
will only be one Foo<T>::bar for each possible T? I assume the
compiler generates storage for Foo<T>::bar in every translation
unit that instantiates Foo<T> and tasks the linker with stripping
any duplicates?