Created on 2023-08-22.00:00:00 last changed 12 months ago
Proposed resolution:
This wording is relative to N4958.
Modify [range.adaptor.object] as indicated:
-1- A range adaptor closure object is a unary function object that accepts a range argument. For a range adaptor closure object C and an expression R such that decltype((R)) models range, the following expressions are equivalent:
[…]
-2- Given an object t of type T, where
(2.1) — t is a unary function object that accepts a range argument and returns a cv-unqualified class object,
[…]
then the implementation ensures that t is a range adaptor closure object.
[ 2023-10-30; Reflector poll ]
Set status to Tentatively NAD.
"The wording says R | C
is equivalent to C(R)
,
not auto(C(R))
."
In order to provide pipe support for user-defined range adaptors, P2387R3 removed the specification that the adaptor closure object returns a view, which conforms to the wording of ranges::to.
However, the current wording seems to be too low-spec so that the range adaptor closure object can return any type or even void. This makes it possible to break the previous specification when returning types that don't make sense, for example:
#include <ranges>
struct Closure : std::ranges::range_adaptor_closure<Closure> {
struct NonCopyable {
NonCopyable(const NonCopyable&) = delete;
};
const NonCopyable& operator()(std::ranges::range auto&&);
};
auto r = std::views::iota(0) | Closure{}; // hard error in libstdc++ and MSVC-STL
Above, since the return type of the pipeline operator is declared as auto, this causes the deleted copy constructor to be invoked in the function body and produces a hard error.
The proposed resolution adds a specification for the range adaptor closure object to return a cv-unqualified class type.History | |||
---|---|---|---|
Date | User | Action | Args |
2023-10-30 17:22:20 | admin | set | messages: + msg13793 |
2023-10-30 17:22:20 | admin | set | status: new -> nad |
2023-09-23 14:03:32 | admin | set | messages: + msg13730 |
2023-08-22 00:00:00 | admin | create |