Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2004-04-25 07:17:26


Hi Pavel

----- Mensaje original -----
De: Pavel Vozenilek <pavel_vozenilek_at_[hidden]>
Fecha: Domingo, Abril 25, 2004 10:11 am
Asunto: [boost] Re: [multi_index] composite keys: request for advice

>
> "Joaquin M Lopez Munoz" <joaquin_at_[hidden]> wrote:
>
> > Composite keys can be specified by a new construct
> > called composite_key in the following manner:
> >
> OT question 1: will it be possible to specify calculated
> index as part of composite index?

I take you mean "calculated key" and "composite key". Yes,
it is possible, composite_key does accept any key extractor,
it needs not be multi_index::member.

>
>
> OT question 2 (I could had asked already): would it be somehow
> possible for calculated index to use user supplied functor
> and then sorting sequenced index according this index?
>
> This would create 'dynamic index', modifiable during runtime.

I'm not quite getting you; the following shows how to specifiy
the comparison predicate at run time, I don't know if this
is what you are asking.

typedef multi_index_container<
  employee,
  indexed_by<
    ordered_unique<
      identity<employee>,
      boost::function<bool (const employee&)>
>
>
> employee_set;
...
bool foo(const employee&);
...
employee_set::ctor_args_list cal;
cal.get<0>.get<1>=foo; // 2nd argument of the first index
employee_set es(cal);

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk