MSTL 1.4.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 null=nullptr) noexcept
 默认构造函数
 function (const function &x)
 复制构造函数
 function (function &&x) noexcept
 移动构造函数
template<typename F, enable_if_t< callable_t< F >::value, int > = 0>
 function (F &&f) noexcept(handler_t< F >::template nothrow_init< F >())
 从任意可调用对象构造
functionoperator= (const function &x)
 复制赋值运算符
functionoperator= (function &&x) noexcept
 移动赋值运算符
functionoperator= (nullptr_t null) noexcept
 空指针赋值运算符
template<typename F, enable_if_t< callable_t< F >::value, int > = 0>
functionoperator= (F &&f) noexcept(handler_t< F >::template nothrow_init< F >())
 从任意可调用对象赋值
template<typename F>
functionoperator= (reference_wrapper< F > f) noexcept
 从引用包装器赋值
void swap (function &x) noexcept
 交换两个function对象
 operator bool () const noexcept
 转换为布尔值
Res operator() (Args &&... args) const noexcept(noexcept(invoker_(func_, _MSTL forward< Args >(args)...)))
 函数调用运算符
MSTL_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参数类型

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

在文件 function.hpp281 行定义.

构造及析构函数说明

◆ function() [1/4]

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

默认构造函数

参数
null空指针字面量

在文件 function.hpp327 行定义.

被这些函数引用 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...)> & x)
inline

复制构造函数

参数
x要复制的function对象

在文件 function.hpp334 行定义.

引用了 _INNER , 以及 function().

◆ function() [3/4]

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

移动构造函数

参数
x要移动的function对象

在文件 function.hpp346 行定义.

引用了 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 && f)
inlinenoexcept

从任意可调用对象构造

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

在文件 function.hpp362 行定义.

引用了 _MSTL , 以及 forward().

成员函数说明

◆ operator bool()

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

转换为布尔值

返回
是否非空

在文件 function.hpp449 行定义.

引用了 empty().

◆ operator()()

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

函数调用运算符

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

在文件 function.hpp457 行定义.

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

◆ operator=() [1/5]

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

复制赋值运算符

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

在文件 function.hpp382 行定义.

引用了 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 && f)
inlinenoexcept

从任意可调用对象赋值

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

在文件 function.hpp418 行定义.

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

◆ operator=() [3/5]

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

移动赋值运算符

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

在文件 function.hpp392 行定义.

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

◆ operator=() [4/5]

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

空指针赋值运算符

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

在文件 function.hpp402 行定义.

引用了 _INNER , 以及 function().

◆ operator=() [5/5]

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

从引用包装器赋值

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

在文件 function.hpp430 行定义.

引用了 function().

◆ swap()

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

交换两个function对象

参数
x要交换的function对象

在文件 function.hpp439 行定义.

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

◆ target() [1/2]

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

获取目标对象的常量指针

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

在文件 function.hpp486 行定义.

被这些函数引用 target().

◆ target() [2/2]

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

获取目标对象的指针

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

在文件 function.hpp496 行定义.

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

◆ target_type()

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

获取目标类型信息

返回
目标类型信息

在文件 function.hpp469 行定义.

引用了 _INNER.


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