Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2005-11-20 19:08:17

----- Mensaje original -----
De: Dylan Trotter <trotterdylan_at_[hidden]>
Fecha: Domingo, Noviembre 20, 2005 8:17 pm
Asunto: [boost] [multi_index] ordered_index should be noncopyable?

> I just had a really irritating time tracking down bad memory access
> in
> ordered_index because I foolishly wrote something like this:
> typedef client_set::nth_index<0>::type address_index_type;
> address_index_type addressIndex = clients_.get<0>();
> address_index_type::iterator iter = addressIndex.find(addr);
> The problem here is that I got my addressIndex by value in the
> second
> line. I may be overlooking something here, but I think it might be
> useful to make ordered_index noncopyable so that this would be
> detected
> at compile time instead of runtime. I nearly threw my monitor out
> the
> window over this one.

Hi Dylan, I'm sorry you had a hard time with that. The truth is,
indices are not copyable; moreover, I comment on this very
mistake you have stumbled upon at the end of the following

So, how come you can compile even when the docs state you
shouldn't? The problem is that some compilers have problems with
template friends (signaled by Boost.Config macro
BOOST_NO_MEMBER_TEMPLATE_FRIENDS) that force me to make (on
these compilers only) some internal index ctors public, hence
your problem. What compiler are you using? MSVC 6.5/7.x/8.0
all have this problem. Most others don't, and on those a
nice compiler error would have popped up when compiling
your snippet.

Again, I'm sorry for the time you might have wasted. At least,
you have refrained from throwing the monitor out of the window :)
Thanx for using Boost.MultiIndex.


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

Boost list run by bdawes at, gregod at, cpdaniel at, john at