C++ 如何访问boost::multi_index::multi_index_container的所有元素<&燃气轮机;根据他们的指数?

C++ 如何访问boost::multi_index::multi_index_container的所有元素<&燃气轮机;根据他们的指数?,c++,boost,C++,Boost,我使用的是boost::multi_index::multi_index_container 以下是我的集装箱声明: typedef boost::multi_index::multi_index_container< myClssPtr, boost::multi_index::indexed_by< OrderdBValue // OrderdBValue this is boost::multi_index::ordered_unique type &g

我使用的是
boost::multi_index::multi_index_container

以下是我的集装箱声明:

typedef boost::multi_index::multi_index_container<
  myClssPtr,
  boost::multi_index::indexed_by<
    OrderdBValue //  OrderdBValue  this is boost::multi_index::ordered_unique type
  >
>
typedef boost::多索引::多索引容器<
myClssPtr,
boost::多索引::按索引索引<
OrderdBValue//OrderdBValue这是boost::multi_index::ordered_唯一类型
>
>

我想按顺序访问此容器的所有元素,如何才能做到这一点?

当然,问题是按什么顺序。但让我假设最直接的解释:

typedef boost::multi_index::multi_index_container<
  myClssPtr,
  boost::multi_index::indexed_by<
    OrderdBValue //  OrderdBValue  this is boost::multi_index::ordered_unique type
  >
> container;

for(myClassPtr& e : container.get<0>())
{
    // e.g.:
    std::cout << e << "\n";
}
typedef boost::多索引::多索引容器<
myClssPtr,
boost::多索引::按索引索引<
OrderdBValue//OrderdBValue这是boost::multi_index::ordered_唯一类型
>
>容器;
for(myClassPtr&e:container.get())
{
//例如:

std::cout Hello@sehe,它会导致以下错误:错误:在“:”标记,如何“:”之前不允许函数定义。将在for循环中工作?使用常规的但带有c++03语法:更新的答案(当然,是时候升级编译器了,或者传递
-std=c++11
!)请参阅文档中的
for(myClassPtr& e : container)
{
    // e.g.:
    std::cout << e << "\n";
}
typedef employee_set::nth_index<0>::type idx_type;
for(idx_type::iterator it=container.get<0>().begin(); it != container.get<0>().end(); ++it)
{
     // e.g.
     std::cout << *it << "\n";
}