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

#include <functional>

Inherits _Mofunc_base.

Public Types

using result_type = _Res
 

Public Member Functions

 move_only_function () noexcept
 
template<typename _Fn , typename _Vt = decay_t<_Fn>>
requires (!is_same_v<_Vt, move_only_function>) && (!__is_in_place_type_v<_Vt>) && __is_callable_from<_Vt>
 move_only_function (_Fn &&__f) noexcept(_S_nothrow_init< _Vt, _Fn >())
 
template<typename _Tp , typename... _Args>
requires is_constructible_v<_Tp, _Args...> && __is_callable_from<_Tp>
 move_only_function (in_place_type_t< _Tp >, _Args &&... __args) noexcept(_S_nothrow_init< _Tp, _Args... >())
 
template<typename _Tp , typename _Up , typename... _Args>
requires is_constructible_v<_Tp, initializer_list<_Up>&, _Args...> && __is_callable_from<_Tp>
 move_only_function (in_place_type_t< _Tp >, initializer_list< _Up > __il, _Args &&... __args) noexcept(_S_nothrow_init< _Tp, initializer_list< _Up > &, _Args... >())
 
 move_only_function (move_only_function &&__x) noexcept
 
 move_only_function (nullptr_t) noexcept
 
 operator bool () const noexcept
 
_Res operator() (_ArgTypes... __args) _GLIBCXX_MOF_CV noexcept(_Noex)
 
template<typename _Fn >
requires is_constructible_v<move_only_function, _Fn>
move_only_functionoperator= (_Fn &&__f) noexcept(is_nothrow_constructible_v< move_only_function, _Fn >)
 
move_only_functionoperator= (move_only_function &&__x) noexcept
 
move_only_functionoperator= (nullptr_t) noexcept
 
void swap (move_only_function &__x) noexcept
 

Friends

bool operator== (const move_only_function &__x, nullptr_t) noexcept
 
void swap (move_only_function &__x, move_only_function &__y) noexcept
 

Detailed Description

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

Polymorphic function wrapper.

Since
C++23

The std::move_only_function class template is a call wrapper similar to std::function, but does not require the stored target function to be copyable.

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

Definition at line 63 of file mofunc_impl.h.

Member Typedef Documentation

◆ result_type

template<typename _Res , typename... _ArgTypes, bool _Noex>
using std::move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::result_type = _Res

Definition at line 80 of file mofunc_impl.h.

Constructor & Destructor Documentation

◆ move_only_function() [1/6]

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

Creates an empty object.

Definition at line 83 of file mofunc_impl.h.

◆ move_only_function() [2/6]

template<typename _Res , typename... _ArgTypes, bool _Noex>
std::move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::move_only_function ( nullptr_t  )
inlinenoexcept

Creates an empty object.

Definition at line 86 of file mofunc_impl.h.

◆ move_only_function() [3/6]

template<typename _Res , typename... _ArgTypes, bool _Noex>
std::move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::move_only_function ( move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> &&  __x)
inlinenoexcept

Moves the target object, leaving the source empty.

Definition at line 89 of file mofunc_impl.h.

◆ move_only_function() [4/6]

template<typename _Res , typename... _ArgTypes, bool _Noex>
template<typename _Fn , typename _Vt = decay_t<_Fn>>
requires (!is_same_v<_Vt, move_only_function>) && (!__is_in_place_type_v<_Vt>) && __is_callable_from<_Vt>
std::move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::move_only_function ( _Fn &&  __f)
inlinenoexcept

Stores a target object initialized from the argument.

Definition at line 98 of file mofunc_impl.h.

◆ move_only_function() [5/6]

template<typename _Res , typename... _ArgTypes, bool _Noex>
template<typename _Tp , typename... _Args>
requires is_constructible_v<_Tp, _Args...> && __is_callable_from<_Tp>
std::move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::move_only_function ( in_place_type_t< _Tp >  ,
_Args &&...  __args 
)
inlineexplicitnoexcept

Stores a target object initialized from the arguments.

Definition at line 116 of file mofunc_impl.h.

◆ move_only_function() [6/6]

template<typename _Res , typename... _ArgTypes, bool _Noex>
template<typename _Tp , typename _Up , typename... _Args>
requires is_constructible_v<_Tp, initializer_list<_Up>&, _Args...> && __is_callable_from<_Tp>
std::move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::move_only_function ( in_place_type_t< _Tp >  ,
initializer_list< _Up >  __il,
_Args &&...  __args 
)
inlineexplicitnoexcept

Stores a target object initialized from the arguments.

Definition at line 129 of file mofunc_impl.h.

Member Function Documentation

◆ operator bool()

template<typename _Res , typename... _ArgTypes, bool _Noex>
std::move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::operator bool ( ) const
inlineexplicitnoexcept

True if a target object is present, false otherwise.

Definition at line 170 of file mofunc_impl.h.

◆ operator()()

template<typename _Res , typename... _ArgTypes, bool _Noex>
_Res std::move_only_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 move_only_function specialization.

Precondition
Must not be empty.

Definition at line 181 of file mofunc_impl.h.

◆ operator=() [1/3]

template<typename _Res , typename... _ArgTypes, bool _Noex>
template<typename _Fn >
requires is_constructible_v<move_only_function, _Fn>
move_only_function & std::move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::operator= ( _Fn &&  __f)
inlinenoexcept

Stores a new target object, initialized from the argument.

Definition at line 160 of file mofunc_impl.h.

◆ operator=() [2/3]

template<typename _Res , typename... _ArgTypes, bool _Noex>
move_only_function & std::move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::operator= ( move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> &&  __x)
inlinenoexcept

Stores a new target object, leaving x empty.

Definition at line 140 of file mofunc_impl.h.

◆ operator=() [3/3]

template<typename _Res , typename... _ArgTypes, bool _Noex>
move_only_function & std::move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::operator= ( nullptr_t  )
inlinenoexcept

Destroys the target object (if any).

Definition at line 149 of file mofunc_impl.h.

◆ swap()

template<typename _Res , typename... _ArgTypes, bool _Noex>
void std::move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)>::swap ( move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> &  __x)
inlinenoexcept

Exchange the target objects (if any).

Definition at line 189 of file mofunc_impl.h.

References std::swap().

Friends And Related Symbol Documentation

◆ operator==

template<typename _Res , typename... _ArgTypes, bool _Noex>
bool operator== ( const move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> &  __x,
nullptr_t   
)
friend

Check for emptiness by comparing with nullptr.

Definition at line 202 of file mofunc_impl.h.

◆ swap

template<typename _Res , typename... _ArgTypes, bool _Noex>
void swap ( move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> &  __x,
move_only_function< _Res(_ArgTypes...) _GLIBCXX_MOF_CV noexcept(_Noex)> &  __y 
)
friend

Exchange the target objects (if any).

Definition at line 197 of file mofunc_impl.h.


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