This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.

2565. std::function's move constructor should guarantee nothrow for reference_wrappers and function pointers

Section: 22.10.17.3.2 [func.wrap.func.con] Status: C++17 Submitter: Tim Song Opened: 2015-12-05 Last modified: 2017-07-30

Priority: 0

View all other issues in [func.wrap.func.con].

View all issues with C++17 status.

Discussion:

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

[2016-02, Issues Telecon]

P0; move to Tentatively Ready.

Proposed resolution:

This wording is relative to N4567.

[Drafting note: The inserted paragraph is a copy of 22.10.17.3.2 [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(i), whose P/R will likely need updating if this wording is adopted.]

  1. Insert after 22.10.17.3.2 [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.