Namespaces
Variants
Actions

std::any::swap

From cppreference.com
< cpp‎ | utility‎ | any
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
 
void swap( any& other ) noexcept;
(since C++17)

Swaps the content of two any objects.

[edit] Parameters

other - object to swap with

[edit] Example

#include <any>
#include <print>
#include <string>
#include <string_view>
 
int main()
{
    std::any a = std::string{"King"};