Deducing first template argument with other template parameters defaulted

后端 未结 2 604
耶瑟儿~
耶瑟儿~ 2020-12-01 14:46

Gcc and clang seem to disagree on whether this code should compile or not:

#include 

template 
struc         


        
2条回答
  •  眼角桃花
    2020-12-01 15:06

    The problem is that MyDelegate doesn't match template class 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 class.

    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