is there a reason why "explicit specialization in non-namespace scope" is still an error in gcc-trunk?

Dennis Luehring dl.soluz@gmx.net
Wed Sep 23 12:42:01 GMT 2020


i've read that scoped template specalization is allowed in C++17


clang supports it starting with release 7

MSVC supports it with VS2017(i don't know what revision)

Intel does not like it


https://gcc.godbolt.org/z/1GET6v

------

enumclass E{ A, B };

struct Ta{ int x; };
struct Tb{ float y; };

struct Mapper
{
template<typename Type> struct type_to_enum{};

template<> // <-- FAILS
struct type_to_enum<Ta>
     {
staticconstexprauto value = E::A;
     };

template <> // <-- Fails
struct type_to_enum<Tb>
     {
staticconstexprauto value = E::B;
     };
};

-------


More information about the Gcc mailing list