Got this code, which was used to compile with the previous version of gcc:
template <int line, typename FuncSig, FuncSig f>
struct HelperWrapper;
template <int line, typename Ret, Ret (&Func)()>
struct HelperWrapper<line, Ret (&)(), Func>
{
static inline int WrapFuncT(const int)
{
return 0;
}
};
template <int line, typename Ret, typename Arg1, Ret (&Func)(Arg1)>
struct HelperWrapper<line, Ret (&)(Arg1), Func>
{
static inline int WrapFuncT(const int)
{
return 1;
}
};
template <int line, typename Ret, typename Arg1, typename Arg2, Ret (&Func)(Arg1, Arg2)>
struct HelperWrapper<line, Ret (&)(Arg1, Arg2), Func>
{
static inline int WrapFuncT(const int)
{
return 2;
}
};
Disabled GCC 7.1.1 with an error:
a.hpp:683:16: error: partial specialization 'struct Type::Implementation::HelperWrapper<line, Ret (&)(), Func>' is not more specialized than [-fpermissive]
struct HelperWrapper<line, Ret (&)(void), Func>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.hpp:640:16: note: primary template 'template<int line, class FuncSig, FuncSig f> struct Type::Implementation::HelperWrapper'
struct HelperWrapper;
^~~~~~~~~~~~~
a.hpp:695:16: error: partial specialization 'struct Type::Implementation::HelperWrapper<line, Ret (&)(Arg1), Func>' is not more specialized than [-fpermissive]
struct HelperWrapper<line, Ret (&)(Arg1), Func>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.hpp:640:16: note: primary template 'template<int line, class FuncSig, FuncSig f> struct Type::Implementation::HelperWrapper'
struct HelperWrapper;
^~~~~~~~~~~~~
a.hpp:707:16: error: partial specialization 'struct Type::Implementation::HelperWrapper<line, Ret (&)(Arg1, Arg2), Func>' is not more specialized than [-fpermissive]
struct HelperWrapper<line, Ret (&)(Arg1, Arg2), Func>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.hpp:640:16: note: primary template 'template<int line, class FuncSig, FuncSig f> struct Type::Implementation::HelperWrapper'
struct HelperWrapper;
I don’t understand the message, since, as I understand it, GCC says that the main template is a direct declaration of the general template structure that does not exist anywhere in the code.
The idea behind this code is to capture the signature and argument type of the function passed.
1) Is GCC right? (If you think this is not the case, please indicate what supports your claims in the current standard)
2) How to fix the code so that it is accepted by GCC (it was adopted from Clang before VisualStudio 2003). I can not use C ++ 11.
: - GCC, , .