Boost logo

Boost Users :

Subject: Re: [Boost-users] Multi_indexcomposite_key
From: isjk (isjk_at_[hidden])
Date: 2010-07-26 01:57:08

there are one hundred million defferent manufacturer, all have "A4", "A8", "A12", "A16"... model car.
 manufacturer and model is many-to-many relationship.</:includetail>
 Particularly large data.</:includetail>
 struct _Modify_price</:includetail>
       _Modify_price(int price_):m_price_(price_){}</:includetail>
       void operator()(car_model& cm_)</:includetail>
                cm_.price = m_price_;</:includetail>
       int m_price_;</:includetail>
  ------------------ ԭʼÓʼþ ------------------
  ·¢¼þÈË: "Joaquin M Lopez Munoz"<joaquin_at_[hidden]>;
 ·¢ËÍʱ¼ä: 2010Äê7ÔÂ26ÈÕ(ÐÇÆÚÒ») Á賿2:49
 ÊÕ¼þÈË: "boost-users"<boost-users_at_[hidden]>;
 Ö÷Ìâ: Re: [Boost-users] Multi_indexcomposite_key

isjk <isjk <at>> writes:

> Oh, sorry.

Nothing to be sorry about. On another topic, please
don't top-post and try to follow the discussion policies
of the list as summarized at

> 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),

Correct, you must change from the example's original
ordered_unique to ordered_no_unique so as to allow cars
with from different manufacturers yet the same 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);

This looks right (haven't compiled it), although a little
contrived: unless you expect to have *many* cars
with the same model name, you can just traverse [im0,im1)
and locate the car you're after.

> ctmv.modify(cctmv, _Modify_price(10000)); // right or wrong???

I don't know how you've defined _Modify_price.
Care to show?

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