Boost logo

Boost Users :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2007-10-01 12:41:58


Hello Jeff,

Jeff Holle ha escrito:

> Once again, I've run into a compilation problem that I can't seem to fix
> and I wish some help.
>
> My multi_index container looks like:
>
> typedef multi_index_container<
> entry,
> indexed_by<
> ordered_unique<member<entry,DataVertex,&entry::m_vertex> >,
> ordered_non_unique<
> composite_key<
> entry,
> member<entry,size_t,&entry::m_y>,
> member<entry,size_t,&entry::m_x>
> >
> >
> >
> > C;
>
> I now have to swap values via the composite_key.
> To simplify things, I'll just express the last of three lines that would
> do this job if it compiles (and the lines needed to understand it).
>
> c.get<1>().modify_key(c.get<1>().find(make_tuple(y,UINT_MAX)),
> ll::_1=make_tuple(y,startIter2->m_x));

This reason why this does not compile as you expect is because the key type
of index #1 in your example is *not* tuple(size_t,size_t), as the code seems to
be asuming. Actually, the key is an instantiation of an opaque template class
called composite_key_result:

http://boost.org/libs/multi_index/doc/reference/key_extraction.html#composite_key_result

As explained in the docs, there is little you can assume about this composite_key_result,
except that B.MI correctly handles it internally. In particular, you cannot assign it
a tuple as you're trying to do, although this operation might seem reasonable at first
sight given that you can look for a tuple in a composite_key-powered index.

So, instead of using modify_key resort to plain modify instead:

  c.get<1>().modify(
    c.get<1>().find(make_tuple(y,UINT_MAX)),
    &ll::_1->*&entry::m_x=startIter2->m_x);

Is your problem solved now?

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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