|
Boost : |
From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2006-02-28 12:38:31
gruenedd_at_[hidden] ha escrito:
> Joaquín Mª López Muñoz wrote:
> > 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)
>
> > ... it implies that a possible outcome
> > of swap_keys() is that both elements get deleted
>
> That`s what i would expect here. :]
> Now, why is this surprising? Consider the following snippet:
>
> multi_index_container<int> c; // default "set"-like
> c.insert(1);
> c.insert(2);
> c.modify_key(--c.end(), _1 = 1);
>
> Isn`t it "surprising" in the same way, that c.size() == 1? ;-)
Yep, well. I don't know, swap_keys's very name seems to indicate
it'll follow std::swap semantics, which certainly doesn't have
elimination of swapped elements as a possibility.
Anyway, the other two reasons I gave for not providing this
feature have more weight in my decision.
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