• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    function
    <ranges>

    std::ranges::iota_view::end

    constexpr auto end() const;                                    // (1)
    constexpr iterator end() const requires same_as<W, Bound>;     // (2)
    

    概要

    番兵を取得する。

    効果

    // (1)
    if constexpr (same_as<Bound, unreachable_sentinel_t>)
      return unreachable_sentinel;
    else
      return sentinel{bound_};
    
    // (2)
    return iterator{bound_};
    

    ただし、bound_iota_viewが内部で保持する末尾の次の値。

    #include <ranges>
    #include <iostream>
    
    int main()
    {
      // .begin と .end を暗黙的に使用
      for (int x : std::views::iota(1, 6)) {
        std::cout << x << '\n';
      }
    }
    

    出力

    1
    2
    3
    4
    5
    

    バージョン

    言語

    • C++20

    処理系

    参照