
Howard Hinnant wrote:
On Jan 8, 2009, at 12:42 PM, Ion Gaztañaga wrote:
is quite problematic for container implementation. With the old emulation (that returned detail::rv<T>) this was possible:
class vector { void push_back(const value_type &); void push_back(boost::detail::rv<value_type>); }
Is it practical to do this instead?
class vector { void push_back(value_type x); // internally move construct from x }
I see that adobe vector has two overloads that are activated with enable_if-like expressions: template <typename U> void push_back(const U& x, typename copy_sink<U, T>::type = template <typename U> void push_back(U x, typename move_sink<U, T>::type = 0); Not that I totally dislike the solution but forwarding is a problem that has a more difficult solution since we can't avoid the overhead for non-movable types. For example: template<class T1, class T2, class T3,... iterator emplace_back(???, ???, ???, ...)? v.emplace_back(t1, boost::move(t2), t3, ...) The same happens when implementing forwarding functions, so I'm starting to think that putting T() in functions taking movable-only types by value is not a bad idea ;-) Regards, Ion