std::ranges:: contiguous_range
|
||||||||||||||||||||||
| Range primitives | |||||||
|
|||||||
| Range concepts | ||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||
| Range factories | |||||||||
|
|||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||
| Helper items | |||||||||||||||||
|
|
||||||||||||||||
|
헤더에 정의됨
<ranges>
|
||
|
template
<
class
T
>
concept contiguous_range
=
|
(C++20 이후) | |
contiguous_range
개념은
range
의 정제된 개념으로,
ranges::begin
이
contiguous_iterator
를 모델로 하는 반복자를 반환하고
ranges::data
커스터마이제이션 포인트를 사용할 수 있는 범위입니다.
의미론적 요구사항
T
는 다음 조건을 만족할 때에만
contiguous_range
를 모델합니다: 표현식
e
가 주어졌을 때
decltype
(
(
e
)
)
가
T
&
이고,
std::
to_address
(
ranges::
begin
(
e
)
)
==
ranges::
data
(
e
)
일 때.
예제
#include <array> #include <deque> #include <list> #include <mdspan> #include <ranges> #include <set> #include <span> #include <string_view> #include <valarray> #include <vector> template<typename T> concept CR = std::ranges::contiguous_range<T>; // zstring이 ranges::contiguous_range라도 ranges::sized_range일 필요는 없음 struct zstring { struct sentinel { friend constexpr bool operator==(const char* str, sentinel) noexcept { return *str == '\0'; } }; const char* str; const char* begin() const noexcept { return str; } sentinel end() const noexcept { return {}; } }; int main() { int a[4]; static_assert( CR<std::vector<int>> and not CR<std::vector<bool>> and not CR<std::deque<int>> and CR<std::valarray<int>> and CR<decltype(a)> and not CR<std::list<int>> and not CR<std::set<int>> and CR<std::array<std::list<int>,42>> and CR<std::string_view> and CR<zstring> and CR<std::span<const int>> and not CR<std::mdspan<int, std::dims<1>>> ); }
참고 항목
|
(C++20)
|
범위가 자신의 크기를 상수 시간에 알 수 있음을 명시
(concept) |
|
(C++20)
|
반복자 타입이
random_access_iterator
를 만족하는 범위를 명시
(concept) |