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.

### 2401. `std::function` needs more `noexcept`

Section: 20.14.17.3 [func.wrap.func] Status: C++17 Submitter: Stephan T. Lavavej Opened: 2014-06-14 Last modified: 2017-07-30

Priority: 0

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

View all issues with C++17 status.

Discussion:

There are two issues here:

1. `std::function`'s constructor from `nullptr_t` is marked as `noexcept`, but its assignment operator from `nullptr_t` isn't. This assignment can and should be marked as `noexcept`.

2. `std::function`'s comparisons with `nullptr_t` are marked as `noexcept` in two out of three places.

[2014-06-16 Rapperswil]

Move to Ready

Proposed resolution:

This wording is relative to N3936.

1. Change 20.14 [function.objects] p2, header `<functional>` synopsis, as indicated:

   >     namespace std {
   >       […]
   >       // 20.9.11 polymorphic function wrappers:
   >       […]
   >       template<class R, class... ArgTypes>
   >       bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
   >       template<class R, class... ArgTypes>
   >       bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
   >       template<class R, class... ArgTypes>
   >       bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
   >       template<class R, class... ArgTypes>
   >       bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
   >       […]
   >     }

2. Change 20.14.17.3 [func.wrap.func], class template `function` synopsis, as indicated:

   >     […]
   >     // 20.9.11.2.1, construct/copy/destroy:
   >     […]
   >     function& operator=(nullptr_t) noexcept;
   >     […]

3. Change 20.14.17.3.2 [func.wrap.func.con] before p16 as indicated:

   >     function& operator=(nullptr_t) noexcept;