Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-12-18 06:31:08


Peter Dimov wrote:
> The fact that push_back is a mutating operation in the STL is
> only part of the problem, perhaps the least significant part.
>
> More significant is that the STL provides push_back (or
> push_front) only when it's efficient. It's not in our case.

I am inclined to make it our case as well :).

> An 'append' done this way:
>
> std::copy(first, last, std::back_inserter(c));
>
> {a word from our sponsor:
>
> std::for_each(first, last, boost::bind(&C::push_back, &c, _1));
>
> }
>
> is reasonably efficient, but naively translating it into
> "meta" is not going to win any awards.

It can be reasonably efficient in compile-time world as well.

> Summary of my position:
>
> * The "append" that, well, appends, should be retained under
> its current name. (I can definitely live without its current
> push_back behavior.)
>
> * I see good arguments against providing a "push_back."

I see good arguments against providing a 'push_back' on a container for
which it is not an O(1) operation. I don't see any good arguments against
providing it for the containers that _do_ satisfy these complexity
requirements.

Aleksey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk