• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <iterator>

    std::reverse_iterator::base

    Iterator base() const;           // C++03
    constexpr Iterator base() const; // C++17
    

    概要

    メンバ変数として保持している、元のイテレータを取得する。

    戻り値

    current

    #include <iostream>
    #include <vector>
    #include <iterator>
    
    int main()
    {
      std::vector<int> v = {1, 2, 3};
    
      std::reverse_iterator<decltype(v)::iterator> it(v.begin());
      decltype(v)::iterator base = it.base(); // 元のイテレータ(v.begin())を取得
    
      std::cout << *base << std::endl;
    }
    

    出力

    1
    

    参照