std::basic_string<CharT,Traits,Allocator>:: append_range
From cppreference.net
<
cpp
|
string
|
basic string
C++
Strings library
| Classes | ||||
|
(C++17)
|
||||
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"); }
関連項目
|
末尾に文字を追加する
(公開メンバ関数) |