C++ Logo

std-discussion

Advanced search

C++ 20. The using declaration with a specialization of a template conversion operator.

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Wed, 21 Aug 2019 20:06:31 +0300
I do not understand p.#7 of the section "13.6.2 Member templates".

There is written

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

Consider the following example

#include <iostream>
struct A
{
    int x = 0;
    template <typename T>
    operator T *() const { std::cout << "operator T *()\n"; return ( T * )&x; }
};
template <>
A::operator int *() const { std::cout << "operator int *()\n"; return ( int * )&x; }
struct B : A
{
    using A::operator int *;
};
int main()
{
    B b;

    std::cout << b.operator int *() << '\n';
}
Does not the using declaration using A::operator int *; refer to a specialization of the template conversion operator because there is used the qualified name A::operator int * does it?
With best regards,
Vlad from Moscow

You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com

Received on 2019-08-21 12:08:35