Sharing static members between template instantiations? (impossible?)

后端 未结 2 781
走了就别回头了
走了就别回头了 2021-01-11 18:42

I am doing something that is probably silly, but it would be nice if it worked.

I am attempting to specialize types in a way that I need my own lookup structure that

相关标签:
2条回答
  • 2021-01-11 19:28

    Sounds like you should either just make them global and not worry about it. Perhaps using namespaces is what you want?

    0 讨论(0)
  • 2021-01-11 19:32

    You could add a non-templated base class and move lookupTable into that class:

    class Base
    {
    protected:
        static map<string, internal_t> lookupTable
    };
    
    template<class T, int N>
    class SpecialArray : Base
    {
        //...
    };
    
    0 讨论(0)
提交回复
热议问题