I'm trying to use the "using-declaration" syntax of C++ to expose some methods and operators of a templated base class. I can expose some methods and operators of the base class, but not a templated operator of the templated base class.
Here is an example of what I am trying, I'd like to be able to expose the templated operator A<>
in class B.
template <typename T>
struct A
{
private:
T _t;
public:
A( T t ) : _t( t ) {}
T operator()() const { return _t; }
template <typename V>
operator A<V>() const { return _t; }
};
template <typename T>
struct B : protected A<T>
{
public:
using A<T>::A; // ok
using A<T>::operator(); // ok
// template<typename V>
// using A<T>::operator A<V>; // compile error
};
int main()
{
int w = A<int>( 10 )();
double x = static_cast<A<double>>( A<int>( 10 ) )();
int y = B<int>( 10 )();
// double z static_cast<B<double>>( B<int>( 10 ) )();
return 0;
}
Is there any way to do this in C++11 (or higher)?