Namespaces
Variants

std:: sized_sentinel_for, std:: disable_sized_sentinel_for

From cppreference.net
Iterator library
Iterator concepts
sized_sentinel_for
(C++20)

Iterator primitives
Algorithm concepts and utilities
Indirect callable concepts
Common algorithm requirements
(C++20)
(C++20)
(C++20)
Utilities
(C++20)
Iterator adaptors
Range access
(C++11) (C++14)
(C++14) (C++14)
(C++11) (C++14)
(C++14) (C++14)
(C++17) (C++20)
(C++17)
(C++17)
ヘッダーで定義 <iterator>
template < class S, class I >

concept sized_sentinel_for =
std:: sentinel_for < S, I > &&
! std :: disable_sized_sentinel_for < std:: remove_cv_t < S > ,
std:: remove_cv_t < I >> &&
requires ( const I & i, const S & s ) {
{ s - i } - > std:: same_as < std:: iter_difference_t < I >> ;
{ i - s } - > std:: same_as < std:: iter_difference_t < I >> ;

} ;
(1) (C++20以降)
template < class S, class I >
inline constexpr bool disable_sized_sentinel_for = false ;
(2) (C++20以降)
1) sized_sentinel_for コンセプトは、イテレータ型 I のオブジェクトと番兵型 S のオブジェクトが、定数時間でそれらの間の距離を計算するために減算できることを指定します。
2) disable_sized_sentinel_for 変数テンプレートは、減算が可能であるが実際には sized_sentinel_for コンセプトをモデル化しないイテレータとセンチネルが、このコンセプトを満たすことを防止するために使用できます。
プログラムは cv 修飾されていない非配列オブジェクト型 S および I に対して disable_sized_sentinel_for を特殊化することができます。ただし、少なくとも一方が プログラム定義型 でなければなりません。このような特殊化は 定数式 で使用可能であり、型は const bool を持ちます。

目次

セマンティック要件

i を型 I のイテレータ、 s を型 S のセンチネルとし、 [ i , s ) が範囲を表すものとする。 n ++ i の適用回数の最小値とし、これにより bool ( i == s ) true となるものとする。 I S sized_sentinel_for<S, I> をモデル化するのは、以下の条件がすべて満たされる場合に限る:

等価性保存

標準ライブラリコンセプトの requires expressions で宣言される式は、 equality-preserving であることが要求されます(特に明記されている場合を除く)。

暗黙的な式のバリエーション

定数左辺値オペランドに対して非変更式を使用する requires は、 暗黙的な式バリエーション も要求します。

関連項目

範囲が定数時間でそのサイズを知ることを指定する
(コンセプト)
範囲のサイズに等しい整数を返す
(カスタマイゼーションポイントオブジェクト)