Nim*_*Nim 4 c++ templates boost gcc4
所以,我试图涉及到multi_index_container并且我有一个相当奇怪的编译器错误,首先这里是最简单的例子来证明我的问题(我可能错过了一些简单的东西)......
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/mem_fun.hpp>
namespace multi_index = boost::multi_index;
template <typename _IdType>
class A
{
public:
typedef _IdType IdType;
IdType getId() const { return id; }
private:
IdType id;
};
struct id_index{};
template <typename Traits>
class Container
{
typedef typename Traits::AType AType;
typedef typename AType::IdType IdType;
typedef typename multi_index::multi_index_container<
AType,
multi_index::indexed_by<
// sort by Id
multi_index::ordered_non_unique<multi_index::tag<id_index>, BOOST_MULTI_INDEX_CONST_MEM_FUN(AType, IdType, getId) >
>
> ASet;
typedef typename ASet::template index<id_index>::type::const_iterator a_it;
typedef typename ASet::template index<id_index>::type::reverse_iterator a_rit;
typedef typename ASet::template index<id_index>::type id_index_t;
public:
bool addA(AType const& cA)
{
const id_index_t& os = _cSet.get<id_index>(); // line 1: errors occur here
// .. do stuff
return true;
}
private:
// Instance of the container...
ASet _cSet;
};
struct ATraits
{
typedef A<int> AType;
};
int main(void)
{
Container<ATraits> container;
ATraits::AType a;
container.addA(a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
g ++(gcc 4.4.4,linux)报告的错误是:
error: expected primary-expression before ‘>’ token (@ line 1)
error: expected primary-expression before ‘)’ token (@ line 1)
Run Code Online (Sandbox Code Playgroud)
所以这个工作正常,直到我将Container转换为类模板,在此之后,我得到了这个错误,并且无法解决为什么..
任何想法将不胜感激......
bool addA(AType const& cA)
{
const id_index_t& os = _cSet.template get<id_index>(); // line 1: errors occur here
// .. do stuff
return true;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1328 次 |
| 最近记录: |