
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...
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