|
Boost Users : |
From: Martin (adrianm_at_[hidden])
Date: 2005-04-05 10:11:34
> Hi Martin,
>
> I haven't compiled your code, but I'm pretty confident
> the problem lies in the following: instead of
>
> composite_key<
> BOOST_MULTI_INDEX_MEMBER(tTest, int, x)
> ,BOOST_MULTI_INDEX_MEMBER(tTest, int, y)
> )
>
> you should write
>
> composite_key<
> tTest
> ,BOOST_MULTI_INDEX_MEMBER(tTest, int, x)
> ,BOOST_MULTI_INDEX_MEMBER(tTest, int, y)
> )
>
> i.e. the first parameter of composite_key is the value
> to which the extractors are applied. Please let me know
> if that solves the issue.
That was a quick reply and you are correct. It is the first time I use
composite keys and I followed the examples. My error was that I thought the
first class argument in the examples meant the identity comparison. Looking at
it now I understand how stupid that was.
> Other than that, I'm always eager to get feedback
> from users of the lib, so if you have additional comments
> or suggestions please let me know.
I work a lot with databases and I often have the need to store table like
information in RAM. I often have a structure like
struct table_t {
string key;
std::vector<subtable_t> subtable;
};
The multi_index works perfectly for this.
The only thing I am missing is a way to update the non-key elements in-place.
Often my structures include subtables which means the copy can be expensive
and I don't want to add member functions to update each member.
Currently I do
const_cast<std::vector<subtable>&>(itr->subtable).push_back(xxx);
It would be nice if there was a macro or template that could do it in a safe
way, i.e. ensure index isn't changed.
nonkey(itr->subtable).push_back(xxx);
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