table of contents
- Tumbleweed 2026.11.13-1.1
- Leap-16.0
| std::ranges::subrange::subrange(3) | C++ Standard Libary | std::ranges::subrange::subrange(3) |
NAME¶
std::ranges::subrange::subrange - std::ranges::subrange::subrange
Synopsis¶
subrange() requires std::default_initializable<I> = default; (1) (since C++20) constexpr subrange( /*convertible-to-non-slicing*/<I> auto i, S s ) (2) (since C++20) requires (!/*StoreSize*/); constexpr subrange( /*convertible-to-non-slicing*/<I> auto i, S s,
/*make-unsigned-like-t*/<std::iter_difference_t<I>> n ) (3) (since C++20)
requires (K == ranges::subrange_kind::sized); template< /*different-from*/<subrange> R >
requires ranges::borrowed_range<R> && /*convertible-to-non-slicing*/<ranges::iterator_t<R>, I> && (4) (since C++20) std::convertible_to<ranges::sentinel_t<R>, S> constexpr subrange( R&& r )
requires (!/*StoreSize*/ || ranges::sized_range<R>); template< ranges::borrowed_range R>
requires /*convertible-to-non-slicing*/<ranges::iterator_t<R>, I> && std::convertible_to<ranges::sentinel_t<R>, S> constexpr subrange( R&& r, (5) (since C++20) /*make-unsigned-like-t*/<std::iter_difference_t<I>> n ) requires (K == ranges::subrange_kind::sized)
: subrange{ranges::begin(r), ranges::end(r), n} {}
Constructs a subrange.
For the definitions of /*make-unsigned-like-t*/ and /*different-from*/, see make-unsigned-like-t and different-from respectively.
Data members Overload begin_ end_ size_
(only if StoreSize is true) (1) value-initialized value-initialized
initialized with 0 (2) initialized with std::move(i) initialized with
s N/A (3) initialized with n
initialized with (4) initialized with initialized with
static_cast<decltype(size_ )>
std::move(ranges::begin(r)) ranges::end(r) (ranges::size(r)) (5)
initialized with n
2) If [i, s) is not a valid range, the behavior is undefined. 3)
If any of the following conditions is satisfied, the behavior is undefined:
* [i, s) is not a valid range.
* n == to-unsigned-like (ranges::distance(i, s)) is false.
Parameters¶
i - iterator that denotes the beginning of the range s - sentinel that denotes the end of the range r - range n - size hint, must be equal to the size of the range
Example¶
This section is incomplete
Reason: no example
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior
for overload (4), size_ might be initialized with P2393R1 C++20
ranges::size(r), but it is made the
not always implicitly convertible to the conversion explicit
corresponding unsigned-integer-like type
| 2026.11.10 | http://cppreference.com |