|
Boost : |
From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2006-02-24 09:55:50
Hello David,
gruenedd_at_[hidden] ha escrito:
> Hello,
>
> What is the status of key swapping, issued here[1]?
> Do you see a chance to have this included sometime? :]
Nothing like that has been included in Boost 1.34, and I decided
to finally not implement the idea because:
* It can be simulated externally (admittedly, not in an optimal
fashion).
* I don't see as a commonly wanted feature.
* It implies weird semantics: swapping keys can result
in collisions arising in other indices. Consider for instance:
multi_index_container<
std::pair<int,int>,
indexed_by<
ordered_unique<member<std::pair<int,int>,int,&std::pair<int,int>::first> >,
ordered_unique<identity<std::pair<int,int> > >
>
> c;
c.insert(std::make_pair(0,1));
c.insert(std::make_pair(1,0));
c.insert(std::make_pair(1,1));
c.swap_keys(c.begin(),++c.begin()); // would yield a duplicate element (1,1)
Not that this cannot be handled, but it implies that a possible outcome
of swap_keys() is that both elements get deleted or the operation
rolled back, which is IMHO a little surprising to the unadvertent user.
I'm sorry the answer to your proposal is negative.
> Best Regards,
> David
>
> [1] http://lists.boost.org/boost-users/2005/04/11223.php
On another issue, you might be interested to know that the problem
you brought forward in
http://lists.boost.org/Archives/boost/2005/02/80589.php
has been solved in 1.34, and the very sample snippet you provided
then now compiles and works cleanly. The solution does not follow
your proposed approach, but uses boost::disable_if<> instead.
More info at
http://boost-consulting.com/boost/libs/multi_index/doc/release_notes.html#boost_1_34
(third bullet). Best regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk