Re: [boost] [multi_index] ordered_index should be noncopyable?

----- Mensaje original ----- De: Dylan Trotter <trotterdylan@yahoo.ca> 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 section: http://boost.org/libs/multi_index/doc/tutorial.html#multipe_sort 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. Best, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Hi Joaquín,
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 section:
http://boost.org/libs/multi_index/doc/tutorial.html#multipe_sort
Whoops, guess I skimmed over that part. Sorry about the confusion.
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.
That makes perfect sense. I knew I should have just tried it on gcc to see what happens.
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.
No apologies necessary, my mistake. I'm getting a lot of use out of MultiIndex.
Best,
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Thanks, Dylan Trotter
participants (2)
-
Dylan Trotter
-
JOAQUIN LOPEZ MU?Z