Created on 2009-12-13.00:00:00 last changed 162 months ago
Proposed resolution:
Add to [func.wrap.func.con] paragraph 9:
template<class F> function(F f); template <class F, class A> function(allocator_arg_t, const A& a, F f);9 Requires: F shall be CopyConstructible. f shall be callable for argument types ArgTypes and return type R. The copy constructor and destructor of A shall not throw exceptions.
[ 2009-12-24 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]
I think std::function should require CopyConstructible for the target object.
I initially thought that MoveConstructible was enough, but it's not. If F is move-only then function's copy constructor cannot be called, but because function uses type erasure, F is not known and so the copy constructor cannot be disabled via enable_if. One option would be to throw an exception if you try to copy a function with a non-copyable target type, but I think that would be a terrible idea.
So although the constructors require that the target be initialised by std::move(f), that's only an optimisation, and a copy constructor is required.
History | |||
---|---|---|---|
Date | User | Action | Args |
2011-08-23 20:07:26 | admin | set | status: wp -> c++11 |
2010-10-21 18:28:33 | admin | set | messages: + msg1457 |
2010-10-21 18:28:33 | admin | set | messages: + msg1456 |
2009-12-13 00:00:00 | admin | create |