std::default_sentinel_t, std::default_sentinel
提供: cppreference.com
ヘッダ <iterator> で定義 | ||
struct default_sentinel_t {}; | (1) | (C++20以上) |
inlineconstexpr default_sentinel_t default_sentinel{}; | (2) | (C++20以上) |
1)
default_sentinel_t
は範囲の終わりを表すために使用される空のクラス型です。 範囲の境界を自分で知っているイテレータ型 (std::counted_iterator など) と共に使用できます。2)
default_sentinel
は default_sentinel_t
型の定数です。[編集]例
Run this code
#include <iterator>#include <algorithm>#include <list>#include <iostream> int main(){std::list<int> l{3,1,4,1,5,9,2,6}; std::ranges::copy(std::counted_iterator(std::begin(l), 4), std::default_sentinel, std::ostream_iterator<int>{std::cout, " "});}
出力:
3 1 4 1
[編集]関連項目
(C++20) | 範囲の終端までの距離を追跡するイテレータアダプタ (クラステンプレート) |