Boost logo

Boost Users :

Subject: Re: [Boost-users] std::back_inserter() with move semantics?
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2009-02-06 11:56:15


On Fri, Feb 6, 2009 at 10:30 AM, Robert Dailey <rcdailey_at_[hidden]> wrote:

> Hi,
>
> I'm currently using std::back_inserter on a ptr_vector, and the values
> being inserted are boost::unique_ptr's. back_inserter does simple assignment
> but I need it to call boost::move() on the thing being assigned (inserted).
> Does boost have an algorithm that can do this?
>

I think I'm getting confused. Maybe std::transform needs to move instead of
copy. I'm doing this:

        std::transform(
            definition.tiles.begin(),
            definition.tiles.end(),
            std::back_inserter( tiles ),
            boost::bind( &TileFactory::Create, _1, boost::ref( textures ) )
            );

TileFactory::Create() returns a boost::unique_ptr. This fails because
std::transform cannot simply do assignment, it must call move() on the
rvalue.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net