Title
function<void(ArgTypes...)> does not discard the return value of the target object
Status
c++17
Section
[func.wrap.func]
Submitter
Agustín Bergé

Created on 2014-07-12.00:00:00 last changed 89 months ago

Messages

Date: 2015-05-05.20:42:32

Proposed resolution:

This wording is relative to N4431.

  1. Edit [func.require] as depicted:

    -2- Define INVOKE(f, t1, t2, ..., tN, R) as static_cast<void>(INVOKE(f, t1, t2, ..., tN)) if R is cv void, otherwise INVOKE(f, t1, t2, ..., tN) implicitly converted to R.

  2. Change [func.wrap.func.inv] as depicted:

    R operator()(ArgTypes... args) const;
    

    -1- EffectsReturns: INVOKE(f, std::forward<ArgTypes>(args)..., R) (20.9.2), where f is the target object (20.9.1) of *this.

    -2- Returns: Nothing if R is void, otherwise the return value of INVOKE(f, std::forward<ArgTypes>(args)..., R).

Date: 2015-05-05.20:42:32

[ 2015-05, Lenexa ]

STL provides improved wording. It replaces the current PR, and intentionally leaves [func.wrap.func] unchanged.

Due to [expr]/6, static_cast<void> is correct even when R is const void.

Date: 2014-10-05.00:00:00

[ 2014-10-05 Daniel comments ]

This side-effect was indeed not intended by 870.

Date: 2015-05-05.20:42:32

function<void(ArgTypes...)> should discard the return value of the target object. This behavior was in the original proposal, and it was removed (accidentally?) by the resolution of LWG 870.

Previous resolution [SUPERSEDED]:

  1. Edit [func.wrap.func] paragraph 2:

    A callable object f of type F is Callable for argument types ArgTypes and return type R if the expression INVOKE(f, declval<ArgTypes>()..., R), considered as an unevaluated operand (Clause 5), is well formed ([func.require]) and, if R is not void, implicitly convertible to R.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2015-05-22 18:31:21adminsetstatus: immediate -> wp
2015-05-07 19:30:46adminsetstatus: open -> immediate
2015-05-05 20:45:11adminsetstatus: new -> open
2015-05-05 20:42:32adminsetmessages: + msg7357
2014-10-05 15:06:24adminsetmessages: + msg7103
2014-10-05 15:06:24adminsetmessages: + msg7102
2014-07-12 00:00:00admincreate