◐ Shell
clean mode source ↗

std::default_sentinel_t, std::default_sentinel - cppreference.com

提供: cppreference.com

<tbody> </tbody>

ヘッダ <iterator> で定義

struct default_sentinel_t { };

(1) (C++20以上)

inline constexpr default_sentinel_t default_sentinel{};

(2) (C++20以上)

1) default_sentinel_t は範囲の終わりを表すために使用される空のクラス型です。 範囲の境界を自分で知っているイテレータ型 (std::counted_iterator など) と共に使用できます。

2) default_sentineldefault_sentinel_t 型の定数です。

#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, " "});
}

出力:

関連項目