• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function template
    <string>

    std::basic_string::assign_range

    template <container-compatible-range<charT> R>
    constexpr basic_string& assign_range(R&& rg); // C++23
    

    概要

    Rangeの各要素を再代入する。

    効果

    return assign(basic_string(from_range,forward<R>(rg),get_allocator()));

    戻り値

    *this

    #include <iostream>
    #include <string>
    
    int main()
    {
      std::string s = "str";
      const char a[3] = {'i', 'n', 'g'};
    
      // Rangeを再代入
      s.assign_range(a);
    
      std::cout << s << std::endl;
    }
    

    出力

    ing
    

    関連項目

    名前 説明
    assign コンテナの再代入