C++ 模板函数中出错(使用Boost.Tuples)
有经验的人能提供建议吗?是问题还是关键短语让我自己去研究?这让我陷入了困境。因为C++ 模板函数中出错(使用Boost.Tuples),c++,templates,boost,function-templates,boost-tuples,C++,Templates,Boost,Function Templates,Boost Tuples,有经验的人能提供建议吗?是问题还是关键短语让我自己去研究?这让我陷入了困境。因为get是一个函数模板,而输出的类型取决于模板参数inputierator,所以需要使用模板关键字: In function 'void f(InputIterator)': Line 12: error: expected primary-expression before ')' token compilation terminated due to -Wfatal-errors. output->templat
get
是一个函数模板,而输出的类型取决于模板参数inputierator
,所以需要使用模板
关键字:
In function 'void f(InputIterator)':
Line 12: error: expected primary-expression before ')' token
compilation terminated due to -Wfatal-errors.
output->template get();
有一个很好的说明为什么这是必要的。因为get
是一个函数模板,并且输出的类型取决于模板参数InputIterator
,所以需要使用模板关键字:
In function 'void f(InputIterator)':
Line 12: error: expected primary-expression before ')' token
compilation terminated due to -Wfatal-errors.
output->template get();
这篇文章很好地描述了为什么这是必要的。。我甚至不知道这个关键字存在(在那个上下文中——显然它在上面)。谢谢。我甚至不知道这个关键字存在(在那个上下文中——显然它在上面)。谢谢
output->template get<1>();