我想指定转换A<T>::B为A<U>::B.
template<typename T>
struct A
{
struct B
{
B() {}
template<typename U>
B(const typename A<U>::B& rhs) {}
};
};
int main()
{
A<int>::B x;
A<double>::B y = x;
}
Run Code Online (Sandbox Code Playgroud)
我以为这会这样做,但我得到编译器错误:
从'A <int> :: B'转换为非标量类型'A <double> :: B'request"
为什么我的代码不正确,以及实现所需转换的正确方法是什么?