• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <string>

    std::basic_string::crbegin

    const_reverse_iterator crbegin() const noexcept;           // (1) C++11
    constexpr const_reverse_iterator crbegin() const noexcept; // (1) C++20
    

    概要

    末尾を指す読み取り専用逆イテレータを取得する

    戻り値

    reverse_iterator(end())

    例外

    投げない

    #include <iostream>
    #include <string>
    
    int main()
    {
      std::string s = "hello";
    
      // 末尾への逆イテレータを取得
      decltype(s)::const_reverse_iterator it = s.crbegin();
    
      // イテレータが指している要素を参照
      const char& c = *it;
      std::cout << c << std::endl;
    }
    

    出力

    o
    

    参照