相关疑难解决方法(0)

对'this-> template [somename]'的调用是做什么的?

我已经搜索过这个问题但我找不到任何相关内容.有没有更好的方法在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;
   } 
};
Run Code Online (Sandbox Code Playgroud)

此示例来自Google Code上的ndarray项目,而不是我自己的代码.

c++ templates

23
推荐指数
1
解决办法
6724
查看次数

g ++模板参数错误

我有GetContainer()函数如下.

template<typename I,typename T,typename Container>
Container& ObjCollection<I,T,Container>::GetContainer()
{
    return mContainer;
}
Run Code Online (Sandbox Code Playgroud)

当我使用这个方法如下

template<typename I,typename T>
T& DynamicObjCollection<I,T>::Insert(T& t)
{
    GetContainer().insert(&t);
    return t;
}
Run Code Online (Sandbox Code Playgroud)

我有错误.

error: there are no arguments to ‘GetContainer’ that depend on a template parameter, 
so a declaration of ‘GetContainer’ must be available

error: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of 
an undeclared name is deprecated)
Run Code Online (Sandbox Code Playgroud)

它适用于MSVC,但g ++不是那么宽容.代码有什么问题?

c++ templates g++

16
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×2

templates ×2

g++ ×1