c++ - How to specialize a template sub-class? -


i'm trying specialize template class inside class compiler won't let me. code works outside of class foo not inside , want struct bla private class foo.

class foo {    template<typename ... ts> struct bla;     template<> struct bla<> { static constexpr int x = 1; }; };  error: explicit specialization in non-namespace scope 'class foo' 

you cannot specialize inside class, use:

class foo { public: // can test    template<typename ... ts> struct bla;  };  // specialize outside class template<> class foo::bla<> { static constexpr int x = 1; };   int main() {     std::cout << foo::bla<>::x; } 

Popular posts from this blog