我有下一堂课,并尝试声明成员函数,该函数将返回指向该类型的指针,但下一个代码
template<class Key, int b> class b_plus_tree_inner_node {
auto split() -> decltype(this) {}
};
给了我这样的错误
在顶层无效使用“this”
我可以用另一种方式做到这一点,我现在关于 typedef 的存在,但可能用 decltype 来实现吗?
EDITED:
我想完成这个:
b_plus_tree_inner_node<Key, b>* split() {...}
如果你想要一个member函数在类中声明它:
template<class Key, int b> class b_plus_tree_inner_node {
b_plus_tree_inner_node* split(){}
// also valid:
//b_plus_tree_inner_node<Key, b>* split(){}
};
如果你想要一个非会员函数,将其设为模板:
template<class Key, int b>
b_plus_tree_inner_node<Key, b>* split(){}
该标准确实允许您编写auto split() -> decltype(this) {}
但GCC 4.6还不支持(GCC 4.7的主干支持)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)