Title
std::function's move constructor should guarantee nothrow for reference_wrappers and function pointers
Status
c++17
Section
[func.wrap.func.con]
Submitter
Tim Song

Created on 2015-12-05.00:00:00 last changed 90 months ago

Messages

Date: 2016-02-07.20:24:45

Proposed resolution:

This wording is relative to N4567.

[Drafting note: The inserted paragraph is a copy of [func.wrap.func.con]/5, only changing "copy constructor" to "copy or move constructor". It does not attempt to fix the issue identified in LWG 2370, whose P/R will likely need updating if this wording is adopted.]

  1. Insert after [func.wrap.func.con]/6:

    function(function&& f);
    template <class A> function(allocator_arg_t, const A& a, function&& f);
    

    -6- Effects: If !f, *this has no target; otherwise, move-constructs the target of f into the target of *this, leaving f in a valid state with an unspecified value.

    -?- Throws: Shall not throw exceptions if f's target is a callable object passed via reference_wrapper or a function pointer. Otherwise, may throw bad_alloc or any exception thrown by the copy or move constructor of the stored callable object. [Note: Implementations are encouraged to avoid the use of dynamically allocated memory for small callable objects, for example, where f's target is an object holding only a pointer or reference to an object and a member function pointer. — end note]

Date: 2016-02-07.20:24:45

[ 2016-02, Issues Telecon ]

P0; move to Tentatively Ready.

Date: 2015-12-16.20:28:09

[func.wrap.func.con]/5 guarantees that copying a std::function whose "target is a callable object passed via reference_wrapper or a function pointer" does not throw exceptions, but the standard doesn't provide this guarantee for the move constructor, which makes scant sense.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-03-07 04:11:48adminsetstatus: ready -> wp
2016-02-07 20:24:45adminsetmessages: + msg7960
2016-02-07 20:24:45adminsetstatus: new -> ready
2015-12-16 20:12:19adminsetmessages: + msg7652
2015-12-05 00:00:00admincreate