Gcc and clang seem to disagree on whether this code should compile or not:
#include
template
struc
The problem is that MyDelegate doesn't match template because receive two template parameter: a type (Signature) and an int (N).
Yes: the second one has a default value. But the signature remain template .
So I suppose g++ is wrong (compiling without error) and clang++ is right. Rakete1111 corrected me (thanks!): your code was wrong before C++17 but correct starting from C++17 (see his answer for the references). So (you're compiling C++17) g++ is right and clang++ is wrong.
A possible solution (waiting for a correct clang++) is define signature_traits as follows
template class Delegate, typename Signature>
struct signature_traits>
{
using type = Signature;
};
or, better IMHO, adding the integer parameter
template class Delegate, typename Signature, int N>
struct signature_traits>
{
using type = Signature;
};
Observe that both solutions are compatible with
static_assert(std::is_same<
void(int, int),
typename signature_traits>::type
>::value);