派生类中的部分专用化(加上奇怪的循环模式)
Partial specialization in a derived class (plus curious recurrent pattern)
我想使用奇怪的循环模式从模板基类派生:
template<typename A, typename B>
struct base
{
typedef A type;
};
template<typename B>
struct derived : public base<derived, B>
{
// Own attributes.
};
但是编译器(g++ 4.7.2)告诉我参数(派生/A)不匹配。
我应该怎么做?
您得到的错误derived
是一个类模板,并且您省略了它的模板参数。 您需要为 derived
指定模板参数:
template<typename B>
struct derived : public base<derived<B>, B>
{
// Own attributes.
};
相关文章:
- C++ 无法在字符数组中使用 for 循环打印字母模式
- 如何在已定义的名称模式上循环
- 防止模式对话框中的事件循环阻塞
- C++ 是否可以使用对变量的引用来简化这种嵌套循环模式?
- 为什么在发布模式下无法访问 for 循环,但在调试中它工作正常
- 我似乎无法弄清楚这种嵌套循环模式C++
- 派生类中的部分专用化(加上奇怪的循环模式)
- 避免虚拟调用循环的模式
- Decorator设计模式:为什么调用链中的函数而不调用循环中的函数
- 非循环访客模式.将接受函数移动到一个位置
- 打破工厂模式中的循环依赖关系
- 使用嵌套 while 循环创建模式
- 嵌套循环:数字模式
- 专门用于访客模式的循环
- 在发布模式下测量Visual Studio(C++)中循环内方法的运行时时出错
- C++中Observer模式实现中的循环引用
- 使用循环和变量模式(序列)
- C/ c++模式:在超时时退出for()循环
- 奇怪的循环模板模式(CRTP),自动列表和c++
- 如何使用具有循环依赖性的组件模式正确地使用多态性