I have a program like this:
template<typename ...Args>
using Function = void(*)(Args *...);
template<typename ...Args>
void DoThing(Function<Args...> func) { }
void IntFunction(int *i) { }
int main(int argc, char *argv[]) {
DoThing(IntFunction);
}
When I run the program, I get this error
$ clang++ -std=c++14 template.cpp
template.cpp:12:3: error: no matching function for call to 'DoThing'
DoThing(IntFunction);
^~~~~~~
template.cpp:7:6: note: candidate template ignored: substitution failure [with Args = int]
void DoThing(Function<Args...> func) { }
^
1 error generated.
But if I compile it with g ++, I get no errors.
It seems that clang is having problems displaying the parameters of the variational pattern when used in a type alias. If I replaced the variable parameters with the standard ones, then I no longer get the error.
Which compiler gives me the correct result? And why wasn’t I allowed to do this?
source
share