Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++17 status.

2487.bind() should beconst-overloaded, notcv-overloaded

Section: 22.10.15.4[func.bind.bind]Status:C++17Submitter: Stephan T. LavavejOpened: 2015-03-27Last modified: 2017-07-30

Priority:2

View all otherissues in [func.bind.bind].

View all issues withC++17 status.

Discussion:

The Standard currently requiresbind() to return something with acv-overloaded function call operator.const is great, butvolatile is not. First, the Library almost always ignoresvolatile's existence (with<type_traits> and<atomic> being rare exceptions). Second, implementations typically store bound arguments in atuple, butget() isn't overloaded forvolatile tuple. Third, when a bound argument is areference_wrapper, we have to calltid.get(), but that won't compile for avolatile reference_wrapper. Finally,const andvolatile don't always have to be handled symmetrically — for example, lambda function call operators areconst by default, but they can't ever bevolatile.

Implementers shouldn't be required to providecv-overloading here. (They can provide it as a conforming extension if they want.)

[2015-05, Lenexa]

JW: why would areference_wrapper be volatile?
STL: if a bound argument is areference_wrapper then in a volatile-qualified operator() that member will be volatile so you can't call get() on it
STL: worded like this it's a conforming extension to kep overloading on volatile
HH: libc++ doesn't overload on volatile
JW: libstdc++ does overload for volatile
MC: move to Ready and bring motion on Friday
10 in favor, none opposed

Proposed resolution:

This wording is relative to N4296.

  1. Change 22.10.15.4[func.bind.bind] as depicted:

    template<class F, class... BoundArgs>unspecified bind(F&& f, BoundArgs&&... bound_args);

    -2-Requires:is_constructible<FD, F>::value shall betrue. For eachTi inBoundArgs,is_constructible<TiD, Ti>::value shall betrue.INVOKE(fd, w1, w2, ..., wN) (20.9.2) shall be a valid expression for some valuesw1,w2, ...,wN, whereN == sizeof...(bound_args).Thecv-qualifierscv of the call wrapperg, as specified below, shall be neithervolatile norconst volatile.

    […]

    template<class R, class F, class... BoundArgs>unspecified bind(F&& f, BoundArgs&&... bound_args);

    -6-Requires:is_constructible<FD, F>::value shall betrue. For eachTi inBoundArgs,is_constructible<TiD, Ti>::value shall betrue.INVOKE(fd, w1, w2, ..., wN) shall be a valid expression for some valuesw1,w2, ...,wN, whereN == sizeof...(bound_args).Thecv-qualifierscv of the call wrapperg, as specified below, shall be neithervolatile norconst volatile.

    […]


[8]ページ先頭

©2009-2026 Movatter.jp