我有multi_index_container
一个索引是composite_key
. 但我找不到一种方法来通过它的键擦除一个元素。请看下面:
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/composite_key.hpp>
using namespace boost::multi_index;
struct Point
{
int x, y;
};
void func()
{
multi_index_container<Point,indexed_by<
hashed_unique<
composite_key<Point,
member<Point,int,&Point::x>,
member<Point,int,&Point::y> >
> > > points;
points.find( boost::make_tuple( 3, 3 ) ); // <- works
points.erase( boost::make_tuple( 3, 3 ) ); // <- failes to compile
}
erase(key)
适用于非复合索引。但我找不到复合键的正确语法。