Boost logo

Boost Users :

Subject: Re: [Boost-users] multi_index_container for composite key
From: Uthpal Urubail (uthpal.urubail_at_[hidden])
Date: 2010-09-09 03:48:19


Joaquín,
My question is:
Can I define container like below?
typedef multi_index_container<
    ElemShell*,
    indexed_by<
    //non-unique as some might have more than ids
    ordered_non_unique<
        composite_key<
            ElemShell*,
            member<ElemShell,int,&ElemShell::N1>,
            member<ElemShell,int,&ElemShell::N2>,
            member<ElemShell,int,&ElemShell::N3>,
            member<ElemShell,int,&ElemShell::N4>
>
>,
    ordered_unique<
    member<GeneralElement,int,&GeneralElement::EID>
>
>
> beambook;

When I retrieve,
        beambook::iterator it=(pb.find(boost::make_tuple(obj->N1,obj->N2,obj->N3,node4)));
        int val = (*it)->N4;
        Application is crashing.

About: If you use ordered_unique then there cannot be two elements with the same node[0], node[1], node[2] values.
Its TRUE. Two elements cannot have same node[0], node[1], node[2] values. How should be the container?

Thanks,
Uthpal


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