GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::ranges::sized_range,std::ranges::disable_sized_range(3) C++ Standard Libary std::ranges::sized_range,std::ranges::disable_sized_range(3)

std::ranges::sized_range,std::ranges::disable_sized_range - std::ranges::sized_range,std::ranges::disable_sized_range


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;


1) The sized_range concept specifies the requirements of a range type that knows its
size in constant time with the size function.
2) disable_sized_range exists to allows 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.


Semantic requirements


1) Given an lvalue t of type std::remove_reference_t<T>, T models sized_range only
if


* ranges::size(t)


* has amortized constant-time complexity,
* does not alter the value of t in a manner observable to
equality-preserving expressions, and
* is equal to ranges::distance(ranges::begin(t), ranges::end(t)), and


* if ranges::iterator_t<T> models forward_iterator, ranges::size(t) is
well-defined regardless of the evaluation of ranges::begin(t) (in other words, a
single-pass sized range may support a call to size only before the first call to
begin, but a forward range must support size at all times).


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


disable_sized_range cannot be specialized for array types or reference types.

// Run this code


#include <ranges>
#include <list>
#include <forward_list>


int main()
{
static_assert(std::ranges::sized_range<std::list<int>>
and not std::ranges::sized_range<std::forward_list<int>>);
}


ranges::random_access_range specifies a range whose iterator type satisfies
(C++20) random_access_iterator
(concept)
ranges::contiguous_range specifies a range whose iterator type satisfies
(C++20) contiguous_iterator
(concept)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.