std::basic_string_view<CharT,Traits>::swap

Exchanges the view with that of v.

# Declarations

constexpr void swap( basic_string_view& v ) noexcept;

(since C++17)

# Parameters

# Return value

(none)

# Example

#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';
}

# See also