• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function template
    <string_view>

    std::operator<<

    namespace std {
      template <class CharT, class Traits>
      std::basic_ostream<CharT, Traits>&
        operator<<(std::basic_ostream<CharT, Traits>& os, std::basic_string_view<CharT, Traits> sv);
    }
    

    概要

    文字列をストリームへ出力する。

    効果

    イテレータ範囲[sv.begin(), sv.end())の文字をosに出力する。

    戻り値

    os

    #include <iostream>
    #include <string_view>
    
    int main()
    {
      std::string_view sv = "Hello World";
    
      std::cout << sv << std::endl;
      std::cout << sv.substr(0, 5) << std::endl;
    }
    

    出力例

    Hello World
    Hello
    

    バージョン

    言語

    • C++17

    処理系