Can I initialize static values at booting code in google test?
<p>I am making a template class which is a interface of id generator class.
I can compile and run the code with google test. And I could confirm staticInitializer() in the following code initializes variable generator_ as non-null value. However, it will be null value in the google test. 
Although I can initialize it in SetUp() function and it works well, I would not like to to modify my code only for google test if possible. </p>

<p>How to initialize static variable which is initialized once at the booting code with google test?</p>

<pre><code>#include &lt;memory&gt;

template&lt;typename Generator&gt;
class IdGenerator {
public:
    using GeneratorType = Generator;
    using ShareGeneratorType = std::shared_ptr&lt;GeneratorType&gt;;

    IdGenerator() {
        staticInitializer();
    };

    static void staticInitializer(void) {
        // This function runs at booting code once. At the time,
        // the following generator_ is non-null value, but it will
        // be null value in google test.
        ShareGeneratorType new_generator = ShareGeneratorType(new Generator());
        generator_ = new_generator;
    }

    template &lt;typename ObjectType&gt;
    static int nextId(void) {
        return generator_-&gt;nextId&lt;ObjectType&gt;();
    }

private:
    static ShareGeneratorType generator_;

};

class IdGeneratorImpl {
public:
    template &lt;typename ObjectType&gt;
    int nextId(void) {
        // ObjectSelector&lt;ObjectType&gt; is a traits class which gives index of ObjectType
        static auto object_index = ObjectSelector&lt;ObjectType&gt;::index;
        return ++id_counters_[object_index];
    }
private:
    static constexpr int no_of_types_ = 4;
    std::array&lt;int, no_of_types_&gt; id_counters_;
};
</code></pre>

<p>The IdGenerator runs and initializes its static member, generator_, from  static_initialization.hpp file.</p>

<pre><code>//static_initialization.hpp
IdGenerator&lt;IdGeneratorImpl&gt; for_static_initializatoin;
</code></pre>