boost@larroy.com ha escrito:
Hi.
I'm trying to create a multi_index and I was wondering if its possible to use a member of a member struct as index.
struct nested_element_t { int i; }; struct element_t { nested_element_t ne; };
I'm not sure if there's a way to use member key extractor or should I write my own
typedef multi_index_container< element_t, indexed_by< ordered_non_unique
> > set_t;
AFAICS you can't use member<> to do that: a member of a member of x is not a member of x. You'll have to resort to a custom key extractor like this: struct element_t_i_extractor { typedef int result_type; int operator()(const element_t& x)const{return x.ne.i;} int& operator()(element_t& x)const{return x.ne.i;} }; Joaquín M López Muñoz Telefónica, Investigación y Desarrollo