NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
function< Res(Args...)> 模板类 参考

通用函数包装器类模板 更多...

#include <function.hpp>

Public 类型

using result_type = Res
 返回类型别名

Public 成员函数

 function (nullptr_t np=nullptr) noexcept
 默认构造函数
 function (const function &other)
 复制构造函数
 function (function &&other) noexcept
 移动构造函数
template<typename F, enable_if_t< callable_t< F >::value, int > = 0>
 function (F &&callable) noexcept(handler_t< F >::template nothrow_init< F >())
 从任意可调用对象构造
functionoperator= (const function &other)
 复制赋值运算符
functionoperator= (function &&other) noexcept
 移动赋值运算符
functionoperator= (nullptr_t np) noexcept
 空指针赋值运算符
template<typename F, enable_if_t< callable_t< F >::value, int > = 0>
functionoperator= (F &&callable) noexcept(handler_t< F >::template nothrow_init< F >())
 从任意可调用对象赋值
template<typename F>
functionoperator= (reference_wrapper< F > wrapper) noexcept
 从引用包装器赋值
void swap (function &other) noexcept
 交换两个function对象
 operator bool () const noexcept
 转换为布尔值
Res operator() (Args &&... args) const
 函数调用运算符
NEFORCE_NODISCARD const std::type_info & target_type () const noexcept
 获取目标类型信息
template<typename F>
const F * target () const noexcept
 获取目标对象的常量指针
template<typename F>
F * target () noexcept
 获取目标对象的指针

详细描述

template<typename Res, typename... Args>
class function< Res(Args...)>

通用函数包装器类模板

模板参数
Res返回类型
Args参数类型

提供类型安全的函数包装,支持存储、复制和调用任意可调用对象。

在文件 functional/function.hpp277 行定义.

构造及析构函数说明

◆ function() [1/4]

template<typename Res, typename... Args>
function< Res(Args...)>::function ( nullptr_t np = nullptr)
inlinenoexcept

默认构造函数

参数
np空指针字面量

在文件 functional/function.hpp321 行定义.

被这些函数引用 function(), function(), operator=(), operator=(), operator=(), operator=(), operator=(), swap() , 以及 target().

◆ function() [2/4]

template<typename Res, typename... Args>
function< Res(Args...)>::function ( const function< Res(Args...)> & other)
inline

复制构造函数

参数
other要复制的function对象

在文件 functional/function.hpp328 行定义.

引用了 function().

◆ function() [3/4]

template<typename Res, typename... Args>
function< Res(Args...)>::function ( function< Res(Args...)> && other)
inlinenoexcept

移动构造函数

参数
other要移动的function对象

在文件 functional/function.hpp341 行定义.

引用了 function().

◆ function() [4/4]

template<typename Res, typename... Args>
template<typename F, enable_if_t< callable_t< F >::value, int > = 0>
function< Res(Args...)>::function ( F && callable)
inlinenoexcept

从任意可调用对象构造

模板参数
F可调用对象类型
参数
callable可调用对象

在文件 functional/function.hpp356 行定义.

引用了 forward(), is_constructible_v , 以及 is_copy_constructible_v.

成员函数说明

◆ operator bool()

template<typename Res, typename... Args>
function< Res(Args...)>::operator bool ( ) const
inlineexplicitnoexcept

转换为布尔值

返回
是否非空

在文件 functional/function.hpp441 行定义.

引用了 empty().

◆ operator()()

template<typename Res, typename... Args>
Res function< Res(Args...)>::operator() ( Args &&... args) const
inline

函数调用运算符

参数
args调用参数
返回
调用结果
异常
memory_exception如果function为空

在文件 functional/function.hpp449 行定义.

引用了 empty() , 以及 forward().

◆ operator=() [1/5]

template<typename Res, typename... Args>
function & function< Res(Args...)>::operator= ( const function< Res(Args...)> & other)
inline

复制赋值运算符

参数
other要赋值的function对象
返回
当前对象的引用

在文件 functional/function.hpp374 行定义.

引用了 function().

◆ operator=() [2/5]

template<typename Res, typename... Args>
template<typename F, enable_if_t< callable_t< F >::value, int > = 0>
function & function< Res(Args...)>::operator= ( F && callable)
inlinenoexcept

从任意可调用对象赋值

模板参数
F可调用对象类型
参数
callable可调用对象
返回
当前对象的引用

在文件 functional/function.hpp410 行定义.

引用了 forward() , 以及 function().

◆ operator=() [3/5]

template<typename Res, typename... Args>
function & function< Res(Args...)>::operator= ( function< Res(Args...)> && other)
inlinenoexcept

移动赋值运算符

参数
other要移动的function对象
返回
当前对象的引用

在文件 functional/function.hpp384 行定义.

引用了 function() , 以及 move().

◆ operator=() [4/5]

template<typename Res, typename... Args>
function & function< Res(Args...)>::operator= ( nullptr_t np)
inlinenoexcept

空指针赋值运算符

参数
np空指针字面量
返回
当前对象的引用

在文件 functional/function.hpp394 行定义.

引用了 function().

◆ operator=() [5/5]

template<typename Res, typename... Args>
template<typename F>
function & function< Res(Args...)>::operator= ( reference_wrapper< F > wrapper)
inlinenoexcept

从引用包装器赋值

模板参数
F可调用对象类型
参数
wrapper引用包装器
返回
当前对象的引用

在文件 functional/function.hpp422 行定义.

引用了 function().

◆ swap()

template<typename Res, typename... Args>
void function< Res(Args...)>::swap ( function< Res(Args...)> & other)
inlinenoexcept

交换两个function对象

参数
other要交换的function对象

在文件 functional/function.hpp431 行定义.

引用了 function() , 以及 swap().

◆ target() [1/2]

template<typename Res, typename... Args>
template<typename F>
const F * function< Res(Args...)>::target ( ) const
inlinenoexcept

获取目标对象的常量指针

模板参数
F目标类型
返回
目标对象的常量指针,如果类型不匹配则返回nullptr

在文件 functional/function.hpp477 行定义.

被这些函数引用 target().

◆ target() [2/2]

template<typename Res, typename... Args>
template<typename F>
F * function< Res(Args...)>::target ( )
inlinenoexcept

获取目标对象的指针

模板参数
F目标类型
返回
目标对象的指针,如果类型不匹配则返回nullptr

在文件 functional/function.hpp487 行定义.

引用了 function() , 以及 target().

◆ target_type()

template<typename Res, typename... Args>
NEFORCE_NODISCARD const std::type_info & function< Res(Args...)>::target_type ( ) const
inlinenoexcept

获取目标类型信息

返回
目标类型信息

在文件 functional/function.hpp460 行定义.


该类的文档由以下文件生成: