我已经搜索了这个问题,但我找不到任何东西。有没有更好的方法在 Google 中查询类似的内容,或者任何人都可以提供一个或多个链接或相当详细的解释?谢谢!
编辑:这是一个例子
template< typename T, size_t N>
struct Vector {
public:
Vector() {
this->template operator=(0);
}
// ...
template< typename U >
typename boost::enable_if< boost::is_convertible< U, T >, Vector& >::type operator=(Vector< U, N > const & other) {
typename Vector< U, N >::ConstIterator j = other.begin();
for (Iterator i = begin(); i != end(); ++i, ++j)
(*i) = (*j);
return *this;
}
};
此示例来自 Google Code 上的 ndarray 项目,不是我自己的代码。
原文由 Phillip Cloud 发布,翻译遵循 CC BY-SA 4.0 许可协议
这是一个需要
this->template
的示例。不过,它与 OP 的示例并不真正匹配:在此示例中,需要
this
否则alloc
不会在基类中查找,因为基类依赖于模板参数T
。template
是必需的,否则用于打开包含 200 的模板参数列表的“<”将指示小于号 ([temp.names]/4)。