
Hi, I try to use multi index container.I have one problem.Please help me.Thanks struct TOrder { char szDate[9]; //date type int nID; // order id int nProductID; //product id double fPrice;// int nVol;// //other member … } // The unique key of TOrder struct is szDdate and nID. How I can typedef the composite_key and the multi_index_container? Thank you for your help. Best regards. Yuan

yuan
Hi, I try to use multi index container.I have one problem. Please help me.Thanks struct TOrder { char szDate[9]; //date type int nID; // order id int nProductID; //product id double fPrice;// int nVol;// //other member … }
The unique key of TOrder struct is szDdate and nID. How I can typedef the composite_key and the multi_index_container?
Assuming that comparison of szDate's is lexicographical, you can
write something like this:
struct DateCompare
{
bool operator()(const char* x,const char* y)const
{
return std::strcmp(x,y)<0;
}
};
typedef multi_index_container<
TOrder,
indexed_by<
ordered_unique<
composite_key<
TOrder,
member
TOrderContainer;
All of this should be explained in the tutorial. Which particular difficulties got you stuck? Thank you, Joaquín M López Muñoz Telefónica Digital
participants (2)
-
Joaquin M Lopez Munoz
-
yuan