# std::function_ref::operator=

> C++ Atlas: `cppatlas.com/w/cpp/utility/functional/function_ref/operator=` | Source: https://en.cppreference.com/w/cpp/utility/functional/function_ref/operator= | Domain: Utility | Standards: C++26

## Official Specification Summary (cppreference)

```cpp
constexpr function_ref& operator=( const function_ref& ) noexcept = default; // (1) (since C++26)

template< class T >
constexpr function_ref& operator=( T ) = delete; // (2) (since C++26)
```

1) Copy assignment operator is explicitly-defaulted. `std::function_ref` satisfies `copyable` and *TriviallyCopyable*. This defaulted assignment operator performs a shallow copy of the stored `thunk-ptr` and `bound-entity`.

2) User-defined assignment operator is explicitly-deleted if `T` is not the same type as `std::function_ref`, `std::is_pointer_v<T>` is `false`, and `T` is not a specialization of `std::nontype_t`. This overload participates in overload resolution only if the constraints are satisfied in the conditions above.

### Return value

`*this`

### See also

- [(constructor)](https://en.cppreference.com/w/cpp/utility/functional/function_ref/function_ref): constructs a new `function_ref` object (public member function)
- [`operator=`](https://en.cppreference.com/w/cpp/utility/functional/copyable_function/operator=): replaces or destroys the target (public member function of `std::copyable_function`)
- [`operator=`](https://en.cppreference.com/w/cpp/utility/functional/function/operator=): assigns a new target (public member function of `std::function<R(Args...)>`)
- [`operator=`](https://en.cppreference.com/w/cpp/utility/functional/move_only_function/operator=): replaces or destroys the target (public member function of `std::move_only_function`)

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