I am using something like the following sections of code to do some initialization. I know that the initialization of p<T>::i_
is unordered. I believe that h
is ordered, so I should be able to reason about the order that it is initialized in. Given that the header for p
is included before the definition of h
, is there any guarantee that p<T>::i_
will be initialized before h
?
struct helper
{
template <typename T>
helper(const T&, int i)
{
p<T>::i_::push_back(i);
}
};
static helper h;
The class p is defined below.
template <typename T>
struct p
{
static std::vector<int> i_;
};
template <typename T>
std::vector<int> p<T>::i_;