Home > Enterprise >  VS2019 explicit specialization requires template<> error with 'using' keyword
VS2019 explicit specialization requires template<> error with 'using' keyword

Time:11-22

I have this piece of c code, and VS2019 to compile it:

#include <iostream>
template<typename t>
class c
{

};

int main(){
    using o = class c<int>;
}

does anybody know why it does not compile, complaining about:

Error   C2906   'c<int>': explicit specialization requires 'template <>'

With mingw-gcc it compiles and runs without error.

Here you can compare compiler outputs: https://godbolt.org/z/55fMzh8qz

Thanks in advance.

CodePudding user response:

class is unnecessary in the using statement, I think visual studio thinks you are trying to declare a specialisation of c:

template <>
class c<int>;

hence the error message.

All you need is:

using o = c<int>;
  • Related