• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <string_view>

    std::basic_string_view::at

    constexpr const_reference at(size_type pos) const;
    

    概要

    任意の位置の文字を取得する。

    戻り値

    return data()[pos];
    

    例外

    pos >= size()の場合、std::out_of_range例外を送出する。

    #include <cassert>
    #include <string_view>
    
    int main()
    {
      std::string_view sv = "Hello World";
    
      char c = sv.at(6);
      assert(c == 'W');
    }
    

    出力

    バージョン

    言語

    • C++17

    処理系