【发布时间】:2012-06-13 05:00:30
【问题描述】:
我有一个类模板Z,当传递一个特定模板N 的任何实例化类型时,我想对其进行专门化:
struct L {
template <typename S> void foo(S &) {/*...*/}
};
template <class T>
struct M {
template <typename S> void foo(S &) {/*...*/}
};
template <class T>
struct N {
template <typename S> void foo(S &) {/*...*/}
};
// I'd like to specialize this for TY==N<anything>
template <typename TX, typename TY>
struct Z {
void bar(TX &tx) { /*...*/ ty->foo(tx); /*...*/ }
TY *ty;
};
由于Z<int, L> 和Z<int, N<int>> 和Z<int, M<int>> 都是有效的用例,我无法将Z 转换为模板模板,并且@ 可以显着降低复杂性987654328@ 当TY 是从N 构建的类时。有没有办法做到这一点?
【问题讨论】:
标签: c++ templates template-specialization boost-mpl template-templates