std::basic_string<CharT,Traits,Allocator>::append_range
Aus de.cppreference.net
template< container-compatible-range<CharT> R >
constexpr std::basic_string& append_range( R&& rg );
|
(seit C++23) | |
Hängt alle Zeichen aus dem Bereich rg an.
Äquivalent zu
return append(std::basic_string( std::from_range, std::forward<R>(rg), get_allocator()));
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
Diesen Code ausführen
#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) |