libstdc++: std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> Class Template Reference

libstdc++

std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> Class Template Reference
Utilities » Function Objects

`#include <functional>`

## Public Types
using | result_type

## Public Member Functions
| copyable_function () noexcept
template<typename _Fn, typename _Vt = decay_t<_Fn>>
| copyable_function (_Fn &&__f) noexcept(_S_nothrow_init< _Vt, _Fn >())
| copyable_function (copyable_function &&__x) noexcept
| copyable_function (copyable_function const &__x)
template<typename _Tp, typename... _Args>
| copyable_function (in_place_type_t< _Tp >, _Args &&... __args) noexcept(_S_nothrow_init< _Tp, _Args... >())
template<typename _Tp, typename _Up, typename... _Args>
| copyable_function (in_place_type_t< _Tp >, initializer_list< _Up > __il, _Args &&... __args) noexcept(_S_nothrow_init< _Tp, initializer_list< _Up > &, _Args... >())
| copyable_function (nullptr_t) noexcept
| operator bool () const noexcept
_Res | operator() (_ArgTypes... __args) _GLIBCXX_MOF_CV noexcept(_Noex)
template<typename _Fn>
copyable_function & | operator= (_Fn &&__f) noexcept(is_nothrow_constructible_v< copyable_function, _Fn >)
copyable_function & | operator= (const copyable_function &__x)
copyable_function & | operator= (copyable_function &&__x) noexcept
copyable_function & | operator= (nullptr_t) noexcept
void | swap (copyable_function &__x) noexcept

## Friends
template<typename _Func>
constexpr auto & | __polyfunc::__base_of (_Func &) noexcept
template<typename _Func>
constexpr auto & | __polyfunc::__invoker_of (_Func &) noexcept
template<typename _Src, typename _Dst>
consteval bool | __polyfunc::__is_invoker_convertible () noexcept
bool | operator== (const copyable_function &__x, nullptr_t) noexcept
void | swap (copyable_function &__x, copyable_function &__y) noexcept

## Detailed Description

template<typename _Res, typename... _ArgTypes, bool _Noex>
class std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>

Polymorphic copyable function wrapper.

Since
  C++26

The std::copyable_function class template is a call wrapper similar to std::function, but it does not provide information about it's target, and preserves constness.

It also supports const-qualification, ref-qualification, and no-throw guarantees. The qualifications and exception-specification of the copyable_function::operator() member function are respected when invoking the target function.

Definition at line 63 of file cpyfunc_impl.h.

## Member Typedef Documentation

## ◆ result_type

template<typename _Res, typename... _ArgTypes, bool _Noex>

using std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::result_type

Definition at line 86 of file cpyfunc_impl.h.

## Constructor & Destructor Documentation

## ◆ copyable_function() [1/7]

template<typename _Res, typename... _ArgTypes, bool _Noex>

std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::copyable_function | ( |  | ) |
| inlinenoexcept

Creates an empty object.

Definition at line 89 of file cpyfunc_impl.h.

References copyable_function().

Referenced by copyable_function(), copyable_function(), copyable_function(), copyable_function(), copyable_function(), copyable_function(), copyable_function(), operator=(), operator=(), operator=(), operator=(), operator==, swap(), and swap.

## ◆ copyable_function() [2/7]

template<typename _Res, typename... _ArgTypes, bool _Noex>

std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::copyable_function | ( | nullptr_t |  | ) |
| inlinenoexcept

Creates an empty object.

Definition at line 92 of file cpyfunc_impl.h.

References copyable_function().

## ◆ copyable_function() [3/7]

template<typename _Res, typename... _ArgTypes, bool _Noex>

std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::copyable_function | ( | copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> && | __x | ) |
| inlinenoexcept

Moves the target object, leaving the source empty.

Definition at line 95 of file cpyfunc_impl.h.

References copyable_function().

## ◆ copyable_function() [4/7]

template<typename _Res, typename... _ArgTypes, bool _Noex>

std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::copyable_function | ( | copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> const & | __x | ) |
| inline

Copies the target object.

Definition at line 101 of file cpyfunc_impl.h.

References copyable_function().

## ◆ copyable_function() [5/7]

template<typename _Res, typename... _ArgTypes, bool _Noex>
template<typename _Fn, typename _Vt = decay_t<_Fn>>

std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::copyable_function | ( | _Fn && | __f | ) |
| inlinenoexcept

Stores a target object initialized from the argument.

Definition at line 110 of file cpyfunc_impl.h.

References copyable_function(), and std::forward().

## ◆ copyable_function() [6/7]

template<typename _Res, typename... _ArgTypes, bool _Noex>
template<typename _Tp, typename... _Args>

std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::copyable_function | ( | in_place_type_t< _Tp > | ,
|  | _Args &&... | __args )
| inlineexplicitnoexcept

Stores a target object initialized from the arguments.

Definition at line 144 of file cpyfunc_impl.h.

References copyable_function(), and std::forward().

## ◆ copyable_function() [7/7]

template<typename _Res, typename... _ArgTypes, bool _Noex>
template<typename _Tp, typename _Up, typename... _Args>

std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::copyable_function | ( | in_place_type_t< _Tp > | ,
|  | initializer_list< _Up > | __il,
|  | _Args &&... | __args )
| inlineexplicitnoexcept

Stores a target object initialized from the arguments.

Definition at line 158 of file cpyfunc_impl.h.

References copyable_function(), and std::forward().

## Member Function Documentation

## ◆ operator bool()

template<typename _Res, typename... _ArgTypes, bool _Noex>

std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::operator bool | ( |  | ) | const
| inlineexplicitnoexcept

True if a target object is present, false otherwise.

Definition at line 213 of file cpyfunc_impl.h.

## ◆ operator()()

template<typename _Res, typename... _ArgTypes, bool _Noex>

_Res std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::operator() | ( | _ArgTypes... | __args | ) |
| inlinenoexcept

Invoke the target object.

The target object will be invoked using the supplied arguments, and as an lvalue or rvalue, and as const or non-const, as dictated by the template arguments of the copyable_function specialization.

Precondition
  Must not be empty.

Definition at line 225 of file cpyfunc_impl.h.

References std::forward(), and operator()().

Referenced by operator()().

## ◆ operator=() [1/4]

template<typename _Res, typename... _ArgTypes, bool _Noex>
template<typename _Fn>

copyable_function & std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::operator= | ( | _Fn && | __f | ) |
| inlinenoexcept

Stores a new target object, initialized from the argument.

Definition at line 203 of file cpyfunc_impl.h.

References copyable_function(), std::forward(), and operator=().

## ◆ operator=() [2/4]

template<typename _Res, typename... _ArgTypes, bool _Noex>

copyable_function & std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::operator= | ( | const copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> & | __x | ) |
| inline

Stores a copy of the source target object.

Definition at line 184 of file cpyfunc_impl.h.

References copyable_function(), and operator=().

## ◆ operator=() [3/4]

template<typename _Res, typename... _ArgTypes, bool _Noex>

copyable_function & std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::operator= | ( | copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> && | __x | ) |
| inlinenoexcept

Stores a new target object, leaving x empty.

Definition at line 170 of file cpyfunc_impl.h.

References copyable_function(), std::addressof(), and operator=().

Referenced by operator=(), operator=(), operator=(), and operator=().

## ◆ operator=() [4/4]

template<typename _Res, typename... _ArgTypes, bool _Noex>

copyable_function & std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::operator= | ( | nullptr_t |  | ) |
| inlinenoexcept

Destroys the target object (if any).

Definition at line 192 of file cpyfunc_impl.h.

References copyable_function(), and operator=().

## ◆ swap()

template<typename _Res, typename... _ArgTypes, bool _Noex>

void std::copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::swap | ( | copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> & | __x | ) |
| inlinenoexcept

Exchange the target objects (if any).

Definition at line 233 of file cpyfunc_impl.h.

References copyable_function(), and swap().

Referenced by swap(), and swap.

## Friends And Related Symbol Documentation

## ◆ operator==

template<typename _Res, typename... _ArgTypes, bool _Noex>

bool operator== | ( | const copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> & | __x,
|  | nullptr_t | )
| friend

Check for emptiness by comparing with nullptr.

Definition at line 246 of file cpyfunc_impl.h.

References copyable_function(), and operator==.

Referenced by operator==.

## ◆ swap

template<typename _Res, typename... _ArgTypes, bool _Noex>

void swap | ( | copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> & | __x,
|  | copyable_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> & | __y )
| friend

Exchange the target objects (if any).

Definition at line 241 of file cpyfunc_impl.h.

References copyable_function(), and swap().

The documentation for this class was generated from the following file:

- cpyfunc_impl.h