• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <iterator>

    std::move_sentinel::コンストラクタ

    constexpr move_sentinel();                              // (1)
    
    constexpr explicit move_sentinel(S s);                  // (2)
    
    template<class S2>
      requires convertible_to<const S2&, S>
    constexpr move_sentinel(const move_sentinel<S2>& s);    // (3)
    

    概要

    move_sentinelオブジェクトを構築する。

    効果

    Sの番兵オブジェクトをlastというメンバ変数に保持しているとする。

    • (1) : last値初期化する(last{}相当の初期化)。
    • (2) : laststd::move(s)によって初期化する。
    • (3) : lasts.lastによって初期化する。

    定数式に評価される条件

    #include <iterator>
    #include <vector>
    
    int main() {
      std::vector<int> vec = {1, 2, 3};
      auto se = std::end(vec);
    
      // (1) デフォルト構築
      std::move_sentinel<std::vector<int>::iterator> ms1{};
    
      // (2) 番兵を渡して構築
      std::move_sentinel ms2{se};
    
      // (3) コピー構築
      std::move_sentinel<std::vector<int>::iterator> ms3{ms2};
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系

    参照