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.

2489. mem_fn() should be noexcept

Section: 22.10.16 [func.memfn] Status: C++17 Submitter: Stephan T. Lavavej Opened: 2015-03-27 Last modified: 2017-07-30

Priority: 0

View all other issues in [func.memfn].

View all issues with C++17 status.

Discussion:

mem_fn() is wide contract and doesn't do anything that could throw exceptions, so it should be marked noexcept.

Note that mem_fn() is perfectly happy to wrap a null PMF/PMD, it just can't be invoked later. This is exactly like std::function, which can be constructed from null PMFs/PMDs. Therefore, mem_fn() will remain wide contract forever.

[2015-05, Lenexa]

Move to Immediate.

Proposed resolution:

This wording is relative to N4296.

  1. Change 22.10 [function.objects] p2 "Header <functional> synopsis" as depicted:

    […]
    // 20.9.11, member function adaptors:
    template<class R, class T> unspecified mem_fn(R T::*) noexcept;
    […]
    
  2. Change 22.10.16 [func.memfn] as depicted:

    template<class R, class T> unspecified mem_fn(R T::* pm) noexcept;
    

    […]

    -4- Throws: Nothing.