std::ranges:: random_access_range
From cppreference.net
C++
Ranges library
|
||||||||||||||||||||||
| Range primitives | |||||||
|
|||||||
| Range concepts | ||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||
| Range factories | |||||||||
|
|||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||
| Helper items | |||||||||||||||||
|
|
||||||||||||||||
|
定義ヘッダー
<ranges>
|
||
|
template
<
class
T
>
concept random_access_range
=
|
(C++20以降) | |
random_access_range
コンセプトは、
range
を改良したものであり、
ranges::begin
が
random_access_iterator
のモデルを返す範囲を表します。
例
このコードを実行
#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>> ); }
関連項目
|
(C++20)
|
範囲がそのサイズを定数時間で知ることを指定する
(コンセプト) |
|
(C++20)
|
イテレータ型が
contiguous_iterator
を満たす範囲を指定する
(コンセプト) |