std::ranges:: contiguous_range
|
||||||||||||||||||||||
| Range primitives | |||||||
|
|||||||
| Range concepts | ||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||
| Range factories | |||||||||
|
|||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||
| Helper items | |||||||||||||||||
|
|
||||||||||||||||
|
Défini dans l'en-tête
<ranges>
|
||
|
template
<
class
T
>
concept contiguous_range
=
|
(depuis C++20) | |
Le concept
contiguous_range
est un raffinement du concept
range
pour lequel
ranges::begin
retourne un modèle de
contiguous_iterator
et le point de personnalisation
ranges::data
est utilisable.
Exigences sémantiques
T
modélise
contiguous_range
uniquement si, étant donné une expression
e
telle que
decltype
(
(
e
)
)
est
T
&
,
std::
to_address
(
ranges::
begin
(
e
)
)
==
ranges::
data
(
e
)
.
Exemple
#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 étant un ranges::contiguous_range n'a pas besoin d'être un 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>>> ); }
Voir aussi
|
(C++20)
|
spécifie qu'un intervalle connaît sa taille en temps constant
(concept) |
|
(C++20)
|
spécifie un intervalle dont le type d'itérateur satisfait
random_access_iterator
(concept) |