std::ranges::random_access_range
Определён в заголовке <ranges> | ||
|---|---|---|
template< class T >
concept random_access_range =
ranges::bidirectional_range<T> && std::random_access_iterator<ranges::iterator_t<T>>;
| (начиная с 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 (концепт) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/ranges/random_access_range