18/03/13 14:03:04.99 cL/fN0Uj0.net
VS2017の15.6.1の環境で
問題なくビルド通るよコンパイラ最新の状態にした方がいいよ
念のためも一度
#include "stdafx.h"
#include <iostream>
template<typename T>
struct A {
};
template<typename T>
struct B {
operator A<T>() {
return A<T>();//このように定義すれば問題はないが
}
operator A<T>()const;//定義を外に出すと関数定義が見つからないと出る。
};
template<typename T>
B<T>::operator A<T>() const {
return A<T>();
}
int main()
{
const B<int> b;
A<int> a = b;
std::cout << "Hello, Wandbox!" << std::endl;
}