std::basic_string<CharT,Traits,Allocator>:: append_range
| Classes | ||||
|
(C++17)
|
||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
template
<
container-compatible-range
<
CharT
>
R
>
constexpr std:: basic_string & append_range ( R && rg ) ; |
(seit C++23) | |
Fügt alle Zeichen aus dem Bereich rg an.
Entspricht
return append(std::basic_string( std::from_range, std::forward<R>(rg), get_allocator()));
Inhaltsverzeichnis |
Parameter
| rg | - | ein container compatible range |
Rückgabewert
* this
Komplexität
Linear in der Größe von rg .
Exceptions
Falls die Operation dazu führen würde, dass
size()
die
max_size()
überschreitet, wird
std::length_error
ausgelöst.
Wenn aus irgendeinem Grund eine Exception ausgelöst wird, hat diese Funktion keine Wirkung ( strong exception safety guarantee ).
Hinweise
| Feature-Test Makro | Wert | Std | Feature |
|---|---|---|---|
__cpp_lib_containers_ranges
|
202202L
|
(C++23) | Memberfunktionen, die container compatible range akzeptieren |
Beispiel
#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"); }
Siehe auch
|
fügt Zeichen am Ende hinzu
(öffentliche Elementfunktion) |