• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <ranges>

    std::ranges::subrange::operator PairLike

    template<different-from<subrange> PairLike>
      requires pair-like-convertible-from<PairLike, const I&, const S&>
    constexpr operator PairLike() const;
    

    概要

    pair-like (大きさ2のtuple-like) な型への変換演算子。

    効果

    return PairLike(begin_, end_);
    

    ただし、begin_end_subrangeが内部で保持するイテレータと番兵。

    #include <ranges>
    #include <cassert>
    
    int main()
    {
      constexpr int a[] = {1, 2};
      const std::ranges::subrange sub(a);
      const std::pair<const int*, const int*> p = sub;
      assert(p.first == a);
      assert(p.second == a + 2);
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系

    参照