Title
mem_fn() should be required to use perfect forwarding
Status
c++17
Section
[func.require]
Submitter
Stephan T. Lavavej

Created on 2015-03-27.00:00:00 last changed 81 months ago

Messages

Date: 2015-05-07.19:30:46

Proposed resolution:

This wording is relative to N4296.

  1. Change [func.require] as depicted [Editorial remark: This simply adds "A simple call wrapper is a forwarding call wrapper", then moves the sentence. — end of remark]:

    -4- Every call wrapper (20.9.1) shall be MoveConstructible. A simple call wrapper is a call wrapper that is CopyConstructible and CopyAssignable and whose copy constructor, move constructor, and assignment operator do not throw exceptions. A forwarding call wrapper is a call wrapper that can be called with an arbitrary argument list and delivers the arguments to the wrapped callable object as references. This forwarding step shall ensure that rvalue arguments are delivered as rvalue-references and lvalue arguments are delivered as lvalue-references. A simple call wrapper is a forwarding call wrapper that is CopyConstructible and CopyAssignable and whose copy constructor, move constructor, and assignment operator do not throw exceptions. [Note: In a typical implementation […] — end note]

Date: 2015-05-07.19:30:46

[ 2015-05, Lenexa ]

Move to Immediate.

Date: 2015-03-27.00:00:00

[func.require]/4 defines "simple call wrapper" and "forwarding call wrapper". Only mem_fn() is specified to be a "simple call wrapper", by [func.memfn]/1: "A simple call wrapper (20.9.1) fn such that the expression fn(t, a2, ..., aN) is equivalent to INVOKE(pm, t, a2, ..., aN) (20.9.2)."

This suggests, but doesn't outright state, that perfect forwarding is involved. It matters for PMFs like R (T::*)(Arg) where Arg is passed by value — if the mem_fn() wrapper's function call operator takes Arg by value, an extra copy/move will be observable. We should require perfect forwarding here.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2015-10-27 16:52:45adminsetstatus: ready -> wp
2015-05-20 14:24:57adminsetstatus: immediate -> ready
2015-05-07 19:30:46adminsetmessages: + msg7370
2015-05-07 19:30:46adminsetstatus: new -> immediate
2015-04-03 16:00:57adminsetmessages: + msg7317
2015-03-27 00:00:00admincreate