Default template argument when using std::enable_if as templ. param.: why OK with two template functions that differ only in the enable_if parameter?

Notes

A common mistake is to declare two function templates that differ only in their default template arguments. This is illegal because default template arguments are not part of function template’s signature, and declaring two different function templates with the same signature is illegal.

Your functions don’t differ only in their default template arguments, they differ in their template parameters, so have different signatures.

In both cases the default template argument is nullptr, but the second template parameter is different in each case.

Leave a Comment