bind's specification doesn't apply the cv-qualification of the call wrapper to the callable objectSection: 22.10.15.4 [func.bind.bind] Status: Resolved Submitter: Tim Song Opened: 2017-05-04 Last modified: 2020-09-06
Priority: 3
View all other issues in [func.bind.bind].
View all issues with Resolved status.
Discussion:
According to 22.10.15.4 [func.bind.bind]/1.2,
fdis an lvalue of typeFDconstructed fromstd::forward<F>(f),
and then uses fd throughout the specification, seemingly without
regard to the cv-qualification of the call wrapper g. But this
definition means that fd is always cv-unqualified, rather than having
its cv-qualification change with that of g as intended.
fd's cv-qualifier followed that of the call wrapper.
A similar issue affects the type of tdi for nested binds.
[2017-07 Toronto Wed Issue Prioritization]
Priority 3
[2020-01 Resolved by the adoption of P1065 in Cologne.]
Proposed resolution:
This wording is relative to N4659.
Edit 22.10.15.4 [func.bind.bind] as indicated:
template<class F, class... BoundArgs> unspecified bind(F&& f, BoundArgs&&... bound_args);[…]
-3- Returns: A forwarding call wrapperg(22.10.4 [func.require]). The effect ofg(u1, u2, ..., uM)shall beINVOKE(static_cast<FD cv &>(fd), std::forward<V1>(v1), std::forward<V2>(v2), ..., std::forward<VN>(vN))where cv represents the cv-qualifiers of
[…]gand the values and types of the bound argumentsv1, v2, . . . , vNare determined as specified below. The copy constructor and move constructor of the forwarding call wrapper shall throw an exception if and only if the corresponding constructor ofFDor of any of the typesTDithrows an exception.template<class R, class F, class... BoundArgs> unspecified bind(F&& f, BoundArgs&&... bound_args);[…]
-7- Returns: A forwarding call wrapperg(22.10.4 [func.require]). The effect ofg(u1, u2, ..., uM)shall beINVOKE<R>(static_cast<FD cv &>(fd), std::forward<V1>(v1), std::forward<V2>(v2), ..., std::forward<VN>(vN))where cv represents the cv-qualifiers of
[…] -10- The values of the bound argumentsgand the values and types of the bound argumentsv1, v2, . . . , vNare determined as specified below. The copy constructor and move constructor of the forwarding call wrapper shall throw an exception if and only if the corresponding constructor ofFDor of any of the typesTDithrows an exception.v1, v2, ... , vNand their corresponding typesV1, V2, ... , VNdepend on the typesTDiderived from the call tobindand the cv-qualifiers cv of the call wrappergas follows:
(10.1) — […]
(10.2) — if the value of
is_bind_expression_v<TDi>istrue, the argument isstatic_cast<TDi cv &>(tdi)(std::forward<Uj>(uj)...)and its typeViisinvoke_result_t<TDi cv &, Uj...>&&;(10.3) — […]