# std::experimental::function<R(Args...)>::swap

> C++ Atlas: `cppatlas.com/w/cpp/experimental/function/swap` | Source: https://en.cppreference.com/w/cpp/experimental/function/swap | Domain: Technical specifications

Exchanges the stored callable objects of *this and other.

## Official Specification Summary (cppreference)

```cpp
void swap( function& other ); // (library fundamentals TS)
```

Exchanges the stored callable objects of `*this` and `other`.

The allocators of `*this` and `other` are not exchanged.

The behavior is undefined if `*this->get_memory_resource() != *other.get_memory_resource()`. (library fundamentals TS) (until library fundamentals TS v3)

The behavior is undefined if `this->get_allocator() != other.get_allocator()`. (library fundamentals TS v3)

### Parameters

- `other` - function wrapper to exchange the stored callable object with

### Return value

(none)

---
Attribution: content from https://en.cppreference.com/w/cpp/experimental/function/swap (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.