C++ Boost multi_index_容器,按标记获取索引导致编译器错误

C++ Boost multi_index_容器,按标记获取索引导致编译器错误,c++,templates,boost,gcc4,C++,Templates,Boost,Gcc4,因此,我试图涉猎multi_index_container,但遇到了一个相当奇怪的编译器错误,首先,这里有一个最简单的例子来说明我的问题(我可能遗漏了一些非常简单的东西) 因此,在我将容器转换为类模板之前,这一切都很顺利,在这之后,我出现了这个错误,并且无法找出原因 如有任何想法,我们将不胜感激……bool addA(AType const&cA) bool addA(AType const& cA) { const id_index_t& os = _cSet.

因此,我试图涉猎
multi_index_container
,但遇到了一个相当奇怪的编译器错误,首先,这里有一个最简单的例子来说明我的问题(我可能遗漏了一些非常简单的东西)

因此,在我将容器转换为类模板之前,这一切都很顺利,在这之后,我出现了这个错误,并且无法找出原因

如有任何想法,我们将不胜感激……

bool addA(AType const&cA)
  bool addA(AType const& cA)
  {
    const id_index_t& os = _cSet.template get<id_index>(); // line 1: errors occur here
    // .. do stuff
    return true;
  }
{ const id_index_t&os=_cSet.template get();//第1行:此处出现错误 //…做事 返回true; }
我真的不知道为什么会发生这种情况,但VC2010编译代码很好@阿拉克,我想这是一个gcc问题,但是@skwllsp的解决方案现在很好用!啊。。。我想这可能很简单!这是模板/类型名地狱。。。实际上,我放弃了,并使用了
get(_cSet)
,但我想我会回到这一点。谢谢@尼姆:不要,自由函数才是出路:)@Metthieu,真的吗?但是,成员函数是否可以利用自由函数可能无法利用的一些实现细节呢?
error: expected primary-expression before ‘>’ token (@ line 1)
error: expected primary-expression before ‘)’ token (@ line 1)
  bool addA(AType const& cA)
  {
    const id_index_t& os = _cSet.template get<id_index>(); // line 1: errors occur here
    // .. do stuff
    return true;
  }