multi_index_container
を使いこなそうとしていて、奇妙なコンパイラエラーが発生しています。まずは、私の問題を示すための最も単純な例です愚かな単純なもの)...ブースト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;
}
グラムで報告されたエラー++(GCC 4.4.4、Linuxの)です:
error: expected primary-expression before ‘>’ token (@ line 1)
error: expected primary-expression before ‘)’ token (@ line 1)
私はクラステンプレートにコンテナを変換するまで、だから、これは素晴らしい仕事をしていました、その後、私はこのエラーを取得し、理由を解決することはできません..
任意のアイデアが...
を理解されるであろう、私は実際に起こっていることですが、VC2010は、コードの罰金をコンパイルする理由はわかりません! – AraK
@AraK、これはgcc odityだと思いますが、@skwllspの解決策は今はうまくいきます! – Nim