Boost logo

Boost :

Subject: Re: [boost] [move][container] Fast-track reviews for Move and Container?
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2009-08-17 11:56:35


Thomas Klimpel escribió:

> But I have a question about Boost.Move: Because the problem
> Boost.Move addresses is so important, and Boost.Move wasn't around,
> my existent code uses efficient implementations of "swap" as a
> substitute. The documentation shows that Boost.Move can be used to
> implement an efficient swap. But what about the other direction? Can
> Boost.Move exploit an existent efficient swap?

Boost.Move calls user defined constructors to operate, so you can
implement your move constructors using your efficient swap:

Type(BOOST_RV_REV(Type) t)
   : ...() //Empty construction
{
   this->swap(t);
}

Ditto for move assignment:

Type & operator=(BOOST_RV_REV(Type) t)
{
   Type tmp(boost::move(t));
   this->swap(tmp);
}

Best,

Ion


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