Question Details

No question body available.

Tags

c++ templates overload-resolution

Answers (1)

Accepted Answer Available
Accepted Answer
July 2, 2026 Score: 4 Rep: 230,689 Quality: Expert Completeness: 100%

If you look at Best Viable function, you might see:

  1. there is at least one argument of F1 whose implicit conversion is better than the corresponding implicit conversion for that argument of F2

And in Rankingofimplicitconversionsequences:

Each type of standard conversion sequence is assigned one of three ranks:

  1. Exact match: no conversion required, lvalue-to-rvalue conversion, qualification conversion, function pointer conversion,(since C++17) user-defined conversion of class type to the same class
  2. Promotion: integral promotion, floating-point promotion
  3. Conversion: integral conversion, floating-point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, boolean conversion, user-defined conversion of a derived class to its base

Here, template void func(const T& ) has rank "exact match" (qualification conversion),
whereas template void func(const BaseT& ) has rank "conversion" ( derived class to its base).

Template being more specialized appears later in case of previous "tie" (#5 in Best Viable function). And it happens with extra template void func(const DerivedT&).