Search code examples
c++templates

Using declaration that refers to member templates of the base class


What is the explanation for the following?

A using-declaration in a derived class cannot refer to a specialization of a template conversion function in a base class."

It is from the ISO C++ Standard ..14.5.2, point 7.


Solution

  • This means that this is ill-formed:

    struct A { template<typename T> operator T(); };
    struct B : A { using A::operator int; }; // ill-formed: refers to specialization
    

    Likewise for other function template specializations (not only conversion functions)

    struct A { template<typename T> void f(); };
    struct B : A { using A::f<int>; }; // ill-formed: refers to specialization