mem_fn()
should be required to use perfect forwardingSection: 22.10.4 [func.require] Status: C++17 Submitter: Stephan T. Lavavej Opened: 2015-03-27 Last modified: 2017-07-30
Priority: 0
View all other issues in [func.require].
View all issues with C++17 status.
Discussion:
22.10.4 [func.require]/4 defines "simple call wrapper" and "forwarding call wrapper". Only mem_fn()
is
specified to be a "simple call wrapper", by 22.10.16 [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)."
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.
[2015-05, Lenexa]
Move to Immediate.
Proposed resolution:
This wording is relative to N4296.
Change 22.10.4 [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 isA 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 isCopyConstructible
andCopyAssignable
and whose copy constructor, move constructor, and assignment operator do not throw exceptions.CopyConstructible
andCopyAssignable
and whose copy constructor, move constructor, and assignment operator do not throw exceptions. [Note: In a typical implementation […] — end note]