Title
std::function should use rvalue swap
Status
cd1
Section
[func.wrap]
Submitter
Daniel Krügler

Created on 2008-01-10.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

In [function.objects], header <functional> synopsis, just below of

template<class R, class... ArgTypes>
  void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
template<class R, class... ArgTypes>
  void swap(function<R(ArgTypes...)>&&, function<R(ArgTypes...)>&);
template<class R, class... ArgTypes>
  void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&&);

In [func.wrap.func] class function definition, change

void swap(function&&);

In [func.wrap.func], just below of

template <class R, class... ArgTypes>
  void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
template <class R, class... ArgTypes>
  void swap(function<R(ArgTypes...)>&&, function<R(ArgTypes...)>&);
template <class R, class... ArgTypes>
  void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&&);

In [func.wrap.func.mod] change

void swap(function&& other);

In [func.wrap.func.alg] add the two overloads

template<class R, class... ArgTypes>
  void swap(function<R(ArgTypes...)>&& f1, function<R(ArgTypes...)>& f2);
template<class R, class... ArgTypes>
  void swap(function<R(ArgTypes...)>& f1, function<R(ArgTypes...)>&& f2);
Date: 2008-01-10.00:00:00

It is expected that typical implementations of std::function will use dynamic memory allocations at least under given conditions, so it seems appropriate to change the current lvalue swappabilty of this class to rvalue swappability.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3715
2008-01-10 00:00:00admincreate