A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../algorithm/../coroutine/../ranges/sized_range.html below:

std::ranges::sized_range, std::ranges::disable_sized_range - cppreference.com

(1) (since C++20)
(until C++26) template< class T >

concept sized_range = ranges::approximately_sized_range<T> &&
    requires(T& t) {
        ranges::size(t);

    };
(since C++26)

template< class >
constexpr bool disable_sized_range = false;

(2) (since C++20) 1)

The

sized_range

concept specifies the requirements of a

range(until C++26)approximately_sized_range(since C++26)

type that knows its size in constant time with the

size

function.

2)

The

disable_sized_range

exists to allow use of range types that provide a

size

function (either as a member or as a non-member) but do not in fact model

sized_range

. Users may specialize

disable_sized_range

for cv-unqualified program-defined types. Such specializations shall be usable in

constant expressions

and have type

const bool

.

[edit] Semantic requirements [edit] Notes

disable_sized_range cannot be used to opt-out a range whose iterator and sentinel satisfy sized_sentinel_for; std::disable_sized_sentinel_for must be used instead.

disable_sized_range cannot be specialized for array types or reference types.

[edit] Example
#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() {}
[edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4