Deducing first template argument with other template parameters defaulted

This is perfectly valid code, and gcc is right. The “feature” was introduced in C++17. It’s not really a feature because it is a defect report. MyDelegate matches the partial specialization of signature_traits, and so it should be taken as gcc correctly does. Note that it works because the second template parameter is defaulted.

The reason why clang doesn’t compile it is because that defect report has a defect :P. It doesn’t introduce the appropriate change in partial ordering, which is not really nice and makes previousy valid code ambiguous again.

It is expected to be fixed soon, but in the meanwhile, clang decided to “hide” the feature behind a flag, -frelaxed-template-template-args.

So, just compile with that flag enabled and you should be fine.

Leave a Comment