Boost logo

Boost :

Subject: Re: [boost] [move] pre-review comments
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2010-04-05 01:22:40


Ion Gaztañaga wrote:
> El 03/04/2010 20:03, Jeffrey Lee Hellrung, Jr. escribió:
>> template< class T >
>> struct my_vector
>> {
>> void push_back(T& x) { /* copy x */ }
>> void push_back(const rv<T>& x) { /* copy x */ }
>> void push_back(rv<T>& x) { /* move x */ }
>> };
>
> I use a similar trick in current interprocess containers, which use the
> other version of the move emulation (the one that does not kick
> move-assignment for rvalues of copyable types. See push_back here:
>
> http://www.boost.org/doc/libs/1_42_0/boost/interprocess/containers/container/vector.hpp

Do you think this technique is worth formalizing?

I've created a macro that will generate overload sets like this (they
look more like your interprocessor push_back's, with templated overloads
that are boost::disable_if'ed out if it binds to a given type), but it's
pretty general (works for functions, member functions, and constructors
with any arity and any number of rvalue types in each positional
parameter you wish to capture), hence pretty complicated. It might be
useful to provide a macro for just the unary case, and just for member
functions (and constructors?).

- Jeff


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