|
|
constexprvoid swap( basic_string_view& v)noexcept; | (since C++17) | |
Exchanges the view with that ofv.
Contents |
v | - | view to swap with |
(none)
Constant.
#include <iostream>#include <string_view> int main(){std::string_view a="AAA";std::string_view b="BBBB"; std::cout<<"Before swap:\n""a = "<< a<<"\n""b = "<< b<<"\n\n"; a.swap(b); std::cout<<"After swap:\n""a = "<< a<<"\n""b = "<< b<<'\n';}
Output:
Before swap:a = AAAb = BBBB After swap:a = BBBBb = AAA
swaps the values of two objects (function template)[edit] | |
swaps two ranges of elements (function template)[edit] | |
swaps the contents (public member function of std::basic_string<CharT,Traits,Allocator> )[edit] |