libstdc++
std::function< _Res(_ArgTypes...)> Class Template Reference

#include <std_function.h>

Inheritance diagram for std::function< _Res(_ArgTypes...)>:
[legend]

Public Types

typedef _Res result_type
 

Public Member Functions

 function () noexcept
 
template<typename _Functor , typename _Constraints = _Requires<_Callable<_Functor>>>
 function (_Functor &&__f) noexcept(_Handler< _Functor >::template _S_nothrow_init< _Functor >())
 
 function (const function &__x)
 
 function (function &&__x) noexcept
 
 function (nullptr_t) noexcept
 
 operator bool () const noexcept
 
_Res operator() (_ArgTypes... __args) const
 
template<typename _Functor >
_Requires< _Callable< _Functor >, function & > operator= (_Functor &&__f) noexcept(_Handler< _Functor >::template _S_nothrow_init< _Functor >())
 
functionoperator= (const function &__x)
 
functionoperator= (function &&__x) noexcept
 
functionoperator= (nullptr_t) noexcept
 
template<typename _Functor >
functionoperator= (reference_wrapper< _Functor > __f) noexcept
 
void swap (function &__x) noexcept
 
const type_infotarget_type () const noexcept
 
template<typename _Functor >
_Functor * target () noexcept
 
template<typename _Functor >
const _Functor * target () const noexcept
 

Detailed Description

template<typename _Res, typename... _ArgTypes>
class std::function< _Res(_ArgTypes...)>

Polymorphic function wrapper.

Since
C++11

Definition at line 334 of file std_function.h.

Member Typedef Documentation

◆ result_type

template<typename _Res , typename... _ArgTypes>
typedef _Res std::function< _Res(_ArgTypes...)>::result_type

Definition at line 360 of file std_function.h.

Constructor & Destructor Documentation

◆ function() [1/5]

template<typename _Res , typename... _ArgTypes>
std::function< _Res(_ArgTypes...)>::function ( )
inlinenoexcept

Default construct creates an empty function call wrapper.

Postcondition
!(bool)*this

Definition at line 368 of file std_function.h.

◆ function() [2/5]

template<typename _Res , typename... _ArgTypes>
std::function< _Res(_ArgTypes...)>::function ( nullptr_t  )
inlinenoexcept

Creates an empty function call wrapper.

Postcondition
!(bool)*this

Definition at line 375 of file std_function.h.

◆ function() [3/5]

template<typename _Res , typename... _ArgTypes>
std::function< _Res(_ArgTypes...)>::function ( const function< _Res(_ArgTypes...)> &  __x)
inline

Function copy constructor.

Parameters
__xA function object with identical call signature.
Postcondition
bool(*this) == bool(__x)

The newly-created function contains a copy of the target of __x (if it has one).

Definition at line 386 of file std_function.h.

◆ function() [4/5]

template<typename _Res , typename... _ArgTypes>
std::function< _Res(_ArgTypes...)>::function ( function< _Res(_ArgTypes...)> &&  __x)
inlinenoexcept

Function move constructor.

Parameters
__xA function object rvalue with identical call signature.

The newly-created function contains the target of __x (if it has one).

Definition at line 404 of file std_function.h.

◆ function() [5/5]

template<typename _Res , typename... _ArgTypes>
template<typename _Functor , typename _Constraints = _Requires<_Callable<_Functor>>>
std::function< _Res(_ArgTypes...)>::function ( _Functor &&  __f)
inlinenoexcept

Builds a function that targets a copy of the incoming function object.

Parameters
__fA function object that is callable with parameters of type ArgTypes... and returns a value convertible to Res.

The newly-created function object will target a copy of __f. If __f is reference_wrapper<F>, then this function object will contain a reference to the function object __f.get(). If __f is a null function pointer, null pointer-to-member, or empty std::function, the newly-created object will be empty.

If __f is a non-null function pointer or an object of type reference_wrapper<F>, this function will not throw.

Definition at line 435 of file std_function.h.

Member Function Documentation

◆ operator bool()

template<typename _Res , typename... _ArgTypes>
std::function< _Res(_ArgTypes...)>::operator bool ( ) const
inlineexplicitnoexcept

Determine if the function wrapper has a target.

Returns
true when this function object contains a target, or false when it is empty.

This function will not throw exceptions.

Definition at line 573 of file std_function.h.

◆ operator()()

template<typename _Res , typename... _ArgTypes>
_Res std::function< _Res(_ArgTypes...)>::operator() ( _ArgTypes...  __args) const
inline

Invokes the function targeted by *this.

Returns
the result of the target.
Exceptions
`bad_function_call`when !(bool)*this

The function call operator invokes the target function object stored by this.

Definition at line 587 of file std_function.h.

◆ operator=() [1/5]

template<typename _Res , typename... _ArgTypes>
template<typename _Functor >
_Requires< _Callable< _Functor >, function & > std::function< _Res(_ArgTypes...)>::operator= ( _Functor &&  __f)
inlinenoexcept

Function assignment to a new target.

Parameters
__fA function object that is callable with parameters of type _ArgTypes... and returns a value convertible to _Res.
Returns
*this
Since
C++11

This function object wrapper will target a copy of __f. If __f is reference_wrapper<F>, then this function object will contain a reference to the function object __f.get(). If __f is a null function pointer or null pointer-to-member, this object will be empty.

If __f is a non-null function pointer or an object of type reference_wrapper<F>, this function will not throw.

Definition at line 531 of file std_function.h.

◆ operator=() [2/5]

template<typename _Res , typename... _ArgTypes>
function & std::function< _Res(_ArgTypes...)>::operator= ( const function< _Res(_ArgTypes...)> &  __x)
inline

Function assignment operator.

Parameters
__xA function with identical call signature.
Postcondition
(bool)*this == (bool)x
Returns
*this

The target of __x is copied to *this. If __x has no target, then *this will be empty.

If __x targets a function pointer or a reference to a function object, then this operation will not throw an exception.

Definition at line 469 of file std_function.h.

◆ operator=() [3/5]

template<typename _Res , typename... _ArgTypes>
function & std::function< _Res(_ArgTypes...)>::operator= ( function< _Res(_ArgTypes...)> &&  __x)
inlinenoexcept

Function move-assignment operator.

Parameters
__xA function rvalue with identical call signature.
Returns
*this

The target of __x is moved to *this. If __x has no target, then *this will be empty.

If __x targets a function pointer or a reference to a function object, then this operation will not throw an exception.

Definition at line 487 of file std_function.h.

References std::move().

◆ operator=() [4/5]

template<typename _Res , typename... _ArgTypes>
function & std::function< _Res(_ArgTypes...)>::operator= ( nullptr_t  )
inlinenoexcept

Function assignment to empty.

Postcondition
!(bool)*this
Returns
*this

The target of *this is deallocated, leaving it empty.

Definition at line 501 of file std_function.h.

◆ operator=() [5/5]

template<typename _Res , typename... _ArgTypes>
template<typename _Functor >
function & std::function< _Res(_ArgTypes...)>::operator= ( reference_wrapper< _Functor >  __f)
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 541 of file std_function.h.

◆ swap()

template<typename _Res , typename... _ArgTypes>
void std::function< _Res(_ArgTypes...)>::swap ( function< _Res(_ArgTypes...)> &  __x)
inlinenoexcept

Swap the targets of two function objects.

Parameters
__xA function with identical call signature.

Swap the targets of this function object and __f. This function will not throw exceptions.

Definition at line 556 of file std_function.h.

References std::swap().

◆ target() [1/2]

template<typename _Res , typename... _ArgTypes>
template<typename _Functor >
const _Functor * std::function< _Res(_ArgTypes...)>::target ( ) const
inlinenoexcept

Access the stored target function object.

Returns
Returns a pointer to the stored target function object, if typeid(_Functor).equals(target_type()); otherwise, a null pointer.

This function does not throw exceptions.

Definition at line 643 of file std_function.h.

◆ target() [2/2]

template<typename _Res , typename... _ArgTypes>
template<typename _Functor >
_Functor * std::function< _Res(_ArgTypes...)>::target ( )
inlinenoexcept

Access the stored target function object.

Returns
Returns a pointer to the stored target function object, if typeid(_Functor).equals(target_type()); otherwise, a null pointer.

This function does not throw exceptions.

Definition at line 632 of file std_function.h.

◆ target_type()

template<typename _Res , typename... _ArgTypes>
const type_info & std::function< _Res(_ArgTypes...)>::target_type ( ) const
inlinenoexcept

Determine the type of the target of this function object wrapper.

Returns
the type identifier of the target function object, or typeid(void) if !(bool)*this.

This function will not throw exceptions.

Definition at line 606 of file std_function.h.


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