Storage class not allowed in explicit specialization

I have the following code in a header file that does not belong to a class:

template<typename Foo> static const Compl<Foo,bar> *foobar (const FBTYPE &x);

template<> static const Compl<typea,bar> *foobar<typea>(const FBTYPE &x) {
    return x.funcA();
}

template<> static const Compl<typeb,bar> *foobar<typeb>(const FBTYPE &x) {
    return x.funcB();
}

The code compiles only with older versions of GCC, but in newer ones I get this error message:

rsvt.h(672): error #3503: a storage class is not allowed in an explicit specialization
  template<> static const Compl<typea,bar> *foobar<typea>(const FBTYPE &x) {
             ^

Any idea why it works with older versions of GCC, but not with newer ones? Also, how can I get it to work with GCC 5?

+4
source share
1 answer

The reason is the following quote, which is now in the C ++ standard: [dcl.stc]/p1

A storage class specifier other than thread_local should not be explicitly specified

+5
source

Source: https://habr.com/ru/post/1663107/


All Articles