std::ranges..._sized_range(3)
π NAME π
okay so bestie, this is the C++ Standard Library page for std::ranges::sized_range,std::ranges::disable_sized_range β yes, that exact comma-smooshed pair β aka std::ranges::sized_range and std::ranges::disable_sized_range. manual name folded in right here so you don't have to squint at a header line π
β¨ Synopsis β¨
Defined in header <ranges>
template< class T >
concept sized_range = ranges::range<T> &&
requires(T& t) { (1) (since C++20)
ranges::size(t);
};
template< class > (2) (since C++20)
inline constexpr bool disable_sized_range = false;
- so (1) is the
sized_rangeconcept: it specifies the requirements of a range type that knows its size in constant time with thesizefunction. lowkey iconic. - and (2)
disable_sized_rangeexists to allow use of range types that provide asizefunction (either as a member or as a non-member) but do not in fact modelsized_range. Users may specializedisable_sized_rangefor cv-unqualified program-defined types. Such specializations shall be usable in constant expressions and have typeconst bool. no cap.
πΈ Notes πΈ
- real talk:
disable_sized_rangecannot be used to opt-out a range whose iterator and sentinel satisfysized_sentinel_for;std::disable_sized_sentinel_formust be used instead. - also important, bestie:
disable_sized_rangecannot be specialized for array types or reference types. periodt.
π¦ Example π¦
run this code, it's giving very demure very mindful:
// Run this code
#include <forward_list>
#include <list>
#include <ranges>
static_assert
(
std::ranges::sized_range<std::list<int>> and
not std::ranges::sized_range<std::forward_list<int>>
);
int main() {}
π See also π
ranges::random_access_rangeβ specifies a range whose iterator type satisfiesrandom_access_iterator(concept) (C++20). iconic.ranges::contiguous_rangeβ specifies a range whose iterator type satisfiescontiguous_iterator(concept) (C++20). slay.
and that's the whole page, bestie! source/version vibes: http://cppreference.com, dated 2024.06.10, page std::ranges..._sized_range(3). bye and go slay your ranges πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms