std::ranges::random_access_range
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Ranges library
(C++23)(C++23)
(C++26)(C++26)
(C++23)(C++23)
(C++26)(C++26)
(C++26)(C++26)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
Defined in header
<ranges>
template< class T >
(since C++20)
concept random_access_range =
The random_access_range
concept is a refinement of range
for which ranges::begin returns a model of random_access_iterator
.
[edit] Example
Run this code
#include <array> #include <deque> #include <list> #include <ranges> #include <set> #include <valarray> #include <vector> template<typename T> concept RAR = std::ranges::random_access_range<T>; int main() { int a[4]; static_assert( RAR<std::vector <int>> and RAR<std::vector <bool>> and RAR<std::deque <int>> and RAR<std::valarray <int>> and RAR<decltype(a)> and not RAR<std::list <int>> and not RAR<std::set <int>> and RAR<std::array <std::list <int>,42>> ); }