Created on 2022-02-27.00:00:00 last changed 34 months ago
Proposed resolution:
This wording is relative to N4901.
Modify [func.wrap.move.ctor] as indicated:
template<class VT> static constexpr bool is-callable-from = see below;-1- If noex is true, is-callable-from<VT> is equal to:
is_nothrow_invocable_r_v<R, VT cv ref, ArgTypes...> &&is_nothrow_invocable_r_v<R, VT inv-quals, ArgTypes...>Otherwise, is-callable-from<VT> is equal to:
is_invocable_r_v<R, VT cv ref, ArgTypes...> &&is_invocable_r_v<R, VT inv-quals, ArgTypes...>
[ 2022-03-04; Reflector poll ]
Set priority to 2 after reflector poll. Probably needs a paper for LEWG.
The following test compiles and holds:
struct X { int operator()() & { return 1; } // #1 int operator()() && { return 2; } // #2 }; using T = move_only_function<int()>; assert(T(X{})() == 1);
In other words, #2 is never used. But if you really remove #2, the code doesn't compile.
The change was introduced between P0288R5 and P0288R6, with an intention (assumed) to require move_only_function<R(Args...) cv> erasing callable objects with operator() without ref-qualifiers. But the actual outcome outlawed programs that were valid when using std::function. It also outlaws future programs such asT x = [captures](this auto&) { return ...; }
where declaring this auto&& without forwarding only to satisfy move_only_function's constraints would be strange.
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-03-04 14:33:52 | admin | set | messages: + msg12403 |
2022-02-27 10:34:17 | admin | set | messages: + msg12387 |
2022-02-27 00:00:00 | admin | create |