Are type aliases used as a parameter parameter type part of the function signature?

Consider an example:

#include <iostream>
#include <vector>

template <class, class T>
using alias = T;

template <template <class...> class>
struct tt_wrapper{};

template <class...>
struct t_wrapper{};

struct A {
    template <template <class...> class TT, class T>
    void foo(alias<tt_wrapper<TT>, T>) { std::cout << "A::foo invoked" << std::endl; }
};

struct B: A {
    using A::foo;
    template <class U, class T>
    void foo(alias<t_wrapper<U>, T>) { std::cout << "B::foo invoked" << std::endl; }
};

int main() {
    B b;
    b.foo<std::vector>(int{});
}

According to [namespace.udecl] / 15 :

When a using declaration brings names from a base class to a derived class, the member functions and member function templates in the class overrides the class and / or hides member functions and member function templates with the same name, parameter list, cv-qualification and ref-qualifier (if any) in the base class (rather than conflicting) .

, -, -. . clang, , , - :

prog.cc:26:7: error: no matching member function for call to 'foo'
    b.foo<std::vector>(int{});
    ~~^~~~~~~~~~~~~~~~
prog.cc:21:10: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'U'
    void foo(alias<t_wrapper<U>, T>) { std::cout << "B::foo invoked" << std::endl; }
         ^
1 error generated.

gcc, . clang?

+4
1

A::foo B::foo

  • (foo)
  • list-type-list (T!!!)
  • cv-qualification ( const, volatile)
  • ref-qualifier ()

.

, .

, - T.

+2

Source: https://habr.com/ru/post/1687703/


All Articles