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,
fd
is an lvalue of typeFD
constructed 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
[…]g
and the values and types of the bound argumentsv1, v2, . . . , vN
are 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 ofFD
or of any of the typesTDi
throws 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 argumentsg
and the values and types of the bound argumentsv1, v2, . . . , vN
are 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 ofFD
or of any of the typesTDi
throws an exception.v1, v2, ... , vN
and their corresponding typesV1, V2, ... , VN
depend on the typesTDi
derived from the call tobind
and the cv-qualifiers cv of the call wrapperg
as 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 typeVi
isinvoke_result_t<TDi cv &, Uj...>&&
;(10.3) — […]