|
Boost Users : |
Subject: Re: [Boost-users] boost::multi_index
From: Igor R (boost.lists_at_[hidden])
Date: 2011-04-06 16:30:48
2011/4/6 <ppatel_at_[hidden]>:
> Hello,
>
>
>
> I have a question regarding creating composite key/specifying length for
> arrays while using multi_index container based on following structure.
>
>
>
> struct TestStruct {
>
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â char firstKey[50];
>
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â char secondKeyPart[3];
>
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â uint32_t thirdKeyPart;
>
>                â¦â¦Some other informationâ¦.
>
> };
>
>
>
> Do I really read to specify this lengths for character arrays? If yes, how
> do I do that while specifying key parts as below?
>
> typedef multi_index_container <
>
> TestStruct,
>
> Â indexed_by<
>
> Â Â Â //non-unique as some subscribers might have more than one number
>
> Â Â Â hashed_unique<
>
> Â Â Â Â Â Â composite_key<
>
> Â Â Â Â Â Â Â TestStruct,
>
> Â Â Â Â Â Â Â member<TestStruct, char*, &TestStruct::firstKeyPart>,
>
> Â Â Â Â Â Â Â member<TestStruct, char*, &TestStruct::secondKeyPart>,
>
> Â Â Â Â Â Â Â member<TestStruct, uint32_t, &TestStruct::thirdKeyPart>,
>
> Â Â Â Â Â >
>
> Â Â Â >
>
> Â >
>
>> TS;
The above keys will hash the pointer values, which is probably not
what you want.
If you change plain C arrays to std::string, it will work as you expect.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net