Created on 2023-08-23.00:00:00 last changed 12 months ago
Proposed resolution:
This wording is relative to N4958.
Modify [range.utility.conv.adaptors] as indicated:
template<class C, class... Args> requires (!view<C>) constexpr auto to(Args&&... args); template<template<class...> class C, class... Args> constexpr auto to(Args&&... args);-1- Mandates: For the first overload, C is a cv-unqualified class type.
-2- Returns: A range adaptor closure object ([range.adaptor.object]) f that is a perfect forwarding call wrapper ([func.require]) with the following properties:
(2.1) — It has no target object.
(2.2) — Its bound argument entities bound_args consist of objects of types decay_t<Args>... direct-non-list-initialized with std::forward<Args>(args)..., respectively.
(2.3) — Its call pattern is to<C>(r, bound_args...), where r is the argument used in a function call expression of f.
-?- Remarks: The expression to(args...) is well-formed if and only if the initialization of the bound argument entities of the result, as specified above, are all well-formed.
[ 2023-09-28; Hewill provides alternative wording ]
The new wording form is consistent with the current wording, that is, it has a similar structure with [range.adaptor.object] p1 and [range.adaptor.object] p8.
[ 2023-11-03; Reflector poll ]
Set priority to 3 after reflector poll. Votes split between NAD and using Mandates instead of constraints.
The ranges::to adaptor returns a range adaptor closure object that stores a copy of the decayed parameter pack.
However, the function signature does not constrain the type of arguments, which leads to hard errors within the function body when they cannot be copied (demo):
#include <ranges>
#include <vector>
struct NonMovable {
NonMovable() = default;
NonMovable(NonMovable&&) = delete;
};
int main() {
auto r = std::ranges::to<std::vector>(NonMovable{}); // hard error in MSVC-STL and libc++
}
This wording is relative to N4958.
Modify [ranges.syn], header <ranges> synopsis, as indicated:
#include <compare> // see [compare.syn] #include <initializer_list> // see [initializer.list.syn] #include <iterator> // see [iterator.synopsis] namespace std::ranges { […] // [range.utility.conv], range conversions template<class C, input_range R, class... Args> requires (!view<C>>) constexpr C to(R&& r, Args&&... args); // freestanding template<template<class...> class C, input_range R, class... Args> constexpr auto to(R&& r, Args&&... args); // freestanding template<class C, class... Args> requires (!view<C>) && (constructible_from<decay_t<Args>, Args> && ...) constexpr auto to(Args&&... args); // freestanding template<template<class...> class C, class... Args> requires (constructible_from<decay_t<Args>, Args> && ...) constexpr auto to(Args&&... args); // freestanding […] }
Modify [range.utility.conv.adaptors] as indicated:
template<class C, class... Args> requires (!view<C>) && (constructible_from<decay_t<Args>, Args> && ...) constexpr auto to(Args&&... args); template<template<class...> class C, class... Args> requires (constructible_from<decay_t<Args>, Args> && ...) constexpr auto to(Args&&... args);-1- Mandates: For the first overload, C is a cv-unqualified class type.
-2- Returns: A range adaptor closure object ([range.adaptor.object]) f that is a perfect forwarding call wrapper ([func.require]) with the following properties: […]
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-03 18:08:28 | admin | set | messages: + msg13806 |
2023-10-03 09:52:01 | admin | set | messages: + msg13744 |
2023-09-24 09:51:14 | admin | set | messages: + msg13734 |
2023-08-23 00:00:00 | admin | create |