|
Boost : |
Subject: Re: [boost] [move][container] Review Request (new versions of Boost.Move and Boost.Container in sandbox and vault)
From: Jeffrey Hellrung (jhellrung_at_[hidden])
Date: 2009-08-27 02:12:19
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:
template< class T >
T factory() { ... }
template< class T, ... >
struct vector
{
...
typedef boost::mpl::if_<
boost::is_movable<T>,
BOOST_COPY_ASSIGN_REF( T ),
const T&
>::type const_lvalue_reference_type;
...
push_back(const_lvalue_reference_type value);
push_back(BOOST_RV_REF( T ) value);
};
...
vector<T> v;
v.push_back(factory()); // should call rvalue push_back, right?
AFAIK, if you use push_back(const T&) for movable types (as is
standard), then that overload would be preferred in the absence of true
rvalue references.
What do you think?
- Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk