Template specialization fails on linking

前端 未结 3 1316
一生所求
一生所求 2021-02-15 12:10

I have an issue with template specialization which I would like to understand. I\'m working with Visual C++ 10.0 (2010). I have a class like this:

class Variable         


        
3条回答
  •  忘掉有多难
    2021-02-15 12:33

    Specializing a template doesn't force the compiler to instantiate it (I think that GCC does though); you still need to explicitly tell the compiler to actually instantiate the template. You can do so with explicit template instantiation. Basically, just add this in the source file:

    template std::string VariableManager::get(const std::string& name) const;
    

提交回复
热议问题