1
我想基於其內部參數專門化模板。我正在使用非嚴格的評估,這使得事情變得困難。基於嵌套內部參數的專用模板
專業化應該基於最少的嵌套模式匹配。例如:
template<typename T>
struct data1;
template<typename T>
struct fun1 {
using type = data1<T>;
};
template<typename T>
struct fun2;
template<typename T>
struct fun2<data1<T>> {
using type = data1<T>;
};
fun2<data1<int>> x1; // this works as expected, T=int
fun2<data1<fun1<int>>>::type x2; // this works as expected, T=fun1<int>
fun2<fun1<int>>::type x3; // this should be specialized as fun2<data1<int>>, T=int
fun2<fun2<fun1<int>>>::type x4; // this should be specialized as fun2<data1<int>>, T=int
我該怎麼做?