Boost logo

Boost Users :

Subject: Re: [Boost-users] ¡èMulti_indexcomposite_key~~
From: isjk (isjk_at_[hidden])
Date: 2010-07-25 07:49:09

Oh, sorry.
 Assume "cadillac" have "A4" model, "bmw" have "A4" model too.
 now, if I will querying "A4" 's price, I must kown the manufacturer.
 ordered_no_unique< tag<model>,BOOST_MULTI_INDEX_MEMBER(car_model,std::string,model) >,ct.insert(car_model("A4",cadillac,78901));ct.insert(car_model("A4",bmw,65412));
 index_iterator<car_table,model>::type im0,im1; boost::tuples::tie(im0,im1)=get<model>(ct).equal_range(model);car_table_manufacturer_view ctmv;copy(im0,im1,back_inserter(ctmv));car_table_manufacturer_view::iterator ictmv = ctmv.find(cm);
  ctmv.modify(cctmv, _Modify_price(10000)); // right or wrong???
  ------------------ ԭʼÓʼþ ------------------
  ·¢¼þÈË: "Joaquin M Lopez Munoz"<joaquin_at_[hidden]>;
 ·¢ËÍʱ¼ä: 2010Äê7ÔÂ25ÈÕ(ÐÇÆÚÌì) ÍíÉÏ7:17
 ÊÕ¼þÈË: "boost-users"<boost-users_at_[hidden]>;
 Ö÷Ìâ: Re: [Boost-users]¡èMulti_indexcomposite_key~~

isjk <isjk <at>> writes:

> thanks a lot!
> now, I have a new problem:
> Multi_index example 6: complex searches and forergn keys,
> struct car_manufacturer
> {
> std::string name;
> };
> struct car_model
> {
> std::string model;
> car_manufacturer* manufacturer;
> int price;
> };
> I want use "model, name" to query "price", and I maybe to modify "price".
> How to do it? thanks.

Sorry but your question is not clear to me: what do you mean
by querying "price" using "model, name"? If you know the model
of a car then you just can use find() in the car_table to locate
the element and access the price.

As for modifying, there's a tutorial section on updating elements
of a multi_index_container at

Joaqu¨ªn M L¨®pez Muoz
Telef¨®nica, Investigaci¨®n y Desarrollo

Boost-users mailing list

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at