Boost logo

Boost :

Subject: Re: [boost] [move][container] Review Request (new versions of Boost.Move and Boost.Container in sandbox and vault)
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2009-08-27 04:18:57


Jeffrey Hellrung escribió:
> Ion,
>
> With your current move-emulation approach, it looks like functions like
> vector::push_back could actually capture genuine rvalues, similar to how
> operator= does, via BOOST_COPY_ASSIGN_REF( T ) for movable types T (and
> using const T& for nonmovable types). For example:

Yes, I know that, but I had no time to update containers to take
advantage of this feature. I'll try to do it before the review, I think
you need 3 overloads for C++03 systems:

//const T & for C++0x, const boost::rv<T> & for C++03
push_back(BOOST_COPY_ASSIGN_REF(value_type)v);
//T && for C++0x, boost::rv<T> & for C++03
push_back(BOOST_RV_REF( T ) value);

#ifdef BOOST_HAS_RVALUE_REFS
push_back(value_type & v)
{ push_back(const_cast<const value_type &>(v); }
#endif

However, I haven't found a way to generalize it for perfect forwarding
(emplace, emplace_back) because the template parameters must be deduced
from arguments and that does not work as push_back. I need help from
more talented people ;-)

Best,

Ion


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