Created on 2022-10-20.00:00:00 last changed 25 months ago
Proposed resolution:
This wording is relative to N4917.
Modify [range.repeat.view] as indicated:
namespace std::ranges {
template<move_constructible W, semiregular Bound = unreachable_sentinel_t>
requires (is_object_v<W> && same_as<W, remove_cv_t<W>> &&
(is-integer-like<Bound> || same_as<Bound, unreachable_sentinel_t>))
class repeat_view : public view_interface<repeat_view<W, Bound>> {
private:
// [range.repeat.iterator], class repeat_view::iterator
struct iterator; // exposition only
movable-box<W> value_ = W(); // exposition only, see [range.move.wrap]
Bound bound_ = Bound(); // exposition only
[…]
};
[…]
}
Modify [range.chunk.by.view] as indicated:
namespace std::ranges {
template<forward_range V, indirect_binary_predicate<iterator_t<V>, iterator_t<V>> Pred>
requires view<V> && is_object_v<Pred>
class chunk_by_view : public view_interface<chunk_by_view<V, Pred>> {
V base_ = V(); // exposition only
movable-box<Pred> pred_ = Pred(); // exposition only
// [range.chunk.by.iter], class chunk_by_view::iterator
class iterator; // exposition only
[…]
};
[…]
}
[ 2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Voting → WP. ]
[ 2022-11-01; Reflector poll ]
Set status to Tentatively Ready after nine votes in favour during reflector poll.
Currently, the member variable value_ of repeat_view is initialized with the following expression:
movable-box<W> value_ = W();
which will result in the following unexpected error in libstdc++:
#include <ranges>
int main() {
std::ranges::repeat_view<int> r; // error: could not convert '0' from 'int' to 'std::ranges::__detail::__box<int>'
}
This is because the single-argument constructors of the simple version of movable-box in libstdc++ are declared as explicit, which is different from the conditional explicit declared by the optional's constructor, resulting in no visible conversion between those two types.
For MSVC-STL, the simple version of movable-box does not provide a single-argument constructor, so this form of initialization will also produce a hard error.This may be a bug of existing implementations, but we don't need such "copy-initialization", the default-constructed movable-box already value-initializes the underlying type.
Simply using default initialization, as most other range adaptors do, guarantees consistency, which also eliminates extra move construction.| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
| 2022-11-17 00:42:33 | admin | set | messages: + msg13084 |
| 2022-11-17 00:42:33 | admin | set | status: voting -> wp |
| 2022-11-08 03:46:49 | admin | set | status: ready -> voting |
| 2022-11-01 17:49:23 | admin | set | messages: + msg12912 |
| 2022-11-01 17:49:23 | admin | set | status: new -> ready |
| 2022-10-22 15:36:31 | admin | set | messages: + msg12883 |
| 2022-10-20 00:00:00 | admin | create | |