Namespaces
Variants

std::basic_string<CharT,Traits,Allocator>::append_range

ja.cppreference.net より
 
 
 
std::basic_string
 
template< container-compatible-range<CharT> R >
constexpr std::basic_string& append_range( R&& rg );
(C++23以降)

範囲 rg のすべての文字を末尾に追加します。

以下と同等です。

return append(std::basic_string( std::from_range, std​::​forward<R>(rg), get_allocator()));

パラメータ

rg - a container compatible range

戻り値

* this

計算量

rg のサイズに対して線形。

例外

操作によって size() が max_size() を超える場合、 std::length_error をスローします。

何らかの理由で例外がスローされた場合、この関数は何も効果を及ぼしません( strong exception safety guarantee )。

注記

機能テスト マクロ 値 標準 機能
__cpp_lib_containers_ranges 202202L (C++23) コンテナ互換範囲 を受け入れるメンバー関数

例

#include <cassert>
#include <string>
int main()
{
    std::string head{"long long"};
    const auto tail = {' ', 'i', 'n', 't'};
#ifdef __cpp_lib_containers_ranges
    head.append_range(tail);
#else
    head.append(tail.begin(), tail.end());
#endif
    assert(head == "long long int");
}

関連項目

末尾に文字を追加する
(公開メンバ関数)