NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
any类 参考

任意类型容器 更多...

#include <any.hpp>

Public 成员函数

 any () noexcept
 默认构造函数
 any (const any &other)
 复制构造函数
anyoperator= (const any &other)
 复制赋值运算符
 any (any &&other) noexcept
 移动构造函数
anyoperator= (any &&other) noexcept
 移动赋值运算符
template<typename T, typename VT = decay_t<T>, typename Manager = manage_t<VT>, enable_if_t< is_copy_constructible_v< VT > &&!is_same_v< inplace_construct_tag, VT > &&!is_same_v< VT, any >, int > = 0>
 any (T &&value)
 从值构造
template<typename T, typename VT = decay_t<T>, enable_if_t<!is_same_v< VT, any > &&is_copy_constructible_v< VT >, int > = 0>
anyoperator= (T &&value)
 从值赋值
template<typename T, typename... Args, typename VT = decay_t<T>, typename Manager = manage_t<VT>, enable_if_t< conjunction_v< is_copy_constructible< VT >, is_constructible< VT, Args &&... > >, int > = 0>
 any (inplace_construct_tag, Args &&... args)
 就地构造
template<typename T, typename U, typename... Args, typename VT = decay_t<T>, typename Manager = manage_t<VT>, enable_if_t< conjunction_v< is_copy_constructible< VT >, is_constructible< VT, std::initializer_list< U > &, Args &&... > >, int > = 0>
 any (inplace_construct_tag, std::initializer_list< U > ilist, Args &&... args)
 使用初始化列表就地构造
 ~any ()
 析构函数
template<typename T, typename... Args, typename DT = decay_t<T>, enable_if_t< conjunction_v< is_copy_constructible< DT >, is_constructible< DT, Args &&... > >, int > = 0>
DT & emplace (Args &&... args)
 就地构造值
template<typename T, typename U, typename... Args, typename DT = decay_t<T>, enable_if_t< conjunction_v< is_copy_constructible< DT >, is_constructible< DT, std::initializer_list< U > &, Args &&... > >, int > = 0>
DT & emplace (std::initializer_list< U > ilist, Args &&... args)
 使用初始化列表就地构造
void reset () noexcept
 重置any对象为空
NEFORCE_NODISCARD bool has_value () const noexcept
 检查是否包含值
NEFORCE_NODISCARD const std::type_info & type () const noexcept
 获取存储值的类型信息
void swap (any &rhs) noexcept
 交换两个any对象

详细描述

任意类型容器

可以在运行时存储任何类型的值,提供类型安全的访问机制。 支持复制、移动、类型查询和类型转换操作。

在文件 utility/any.hpp77 行定义.

构造及析构函数说明

◆ any() [1/5]

any::any ( const any & other)

复制构造函数

参数
other源any对象

引用了 any().

◆ any() [2/5]

any::any ( any && other)
noexcept

移动构造函数

参数
other源any对象

引用了 any().

◆ any() [3/5]

template<typename T, typename VT = decay_t<T>, typename Manager = manage_t<VT>, enable_if_t< is_copy_constructible_v< VT > &&!is_same_v< inplace_construct_tag, VT > &&!is_same_v< VT, any >, int > = 0>
any::any ( T && value)
inlineexplicit

从值构造

模板参数
T值类型
参数
value要存储的值

在文件 utility/any.hpp288 行定义.

引用了 forward().

◆ any() [4/5]

template<typename T, typename... Args, typename VT = decay_t<T>, typename Manager = manage_t<VT>, enable_if_t< conjunction_v< is_copy_constructible< VT >, is_constructible< VT, Args &&... > >, int > = 0>
any::any ( inplace_construct_tag ,
Args &&... args )
inlineexplicit

就地构造

模板参数
T值类型
Args参数类型
参数
args构造参数

在文件 utility/any.hpp314 行定义.

引用了 forward().

◆ any() [5/5]

template<typename T, typename U, typename... Args, typename VT = decay_t<T>, typename Manager = manage_t<VT>, enable_if_t< conjunction_v< is_copy_constructible< VT >, is_constructible< VT, std::initializer_list< U > &, Args &&... > >, int > = 0>
any::any ( inplace_construct_tag ,
std::initializer_list< U > ilist,
Args &&... args )
inlineexplicit

使用初始化列表就地构造

模板参数
T值类型
U初始化列表元素类型
Args参数类型
参数
ilist初始化列表
args构造参数

在文件 utility/any.hpp331 行定义.

引用了 forward().

成员函数说明

◆ emplace() [1/2]

template<typename T, typename... Args, typename DT = decay_t<T>, enable_if_t< conjunction_v< is_copy_constructible< DT >, is_constructible< DT, Args &&... > >, int > = 0>
DT & any::emplace ( Args &&... args)
inline

就地构造值

模板参数
T值类型
Args参数类型
参数
args构造参数
返回
构造的值的引用

在文件 utility/any.hpp350 行定义.

引用了 forward().

◆ emplace() [2/2]

template<typename T, typename U, typename... Args, typename DT = decay_t<T>, enable_if_t< conjunction_v< is_copy_constructible< DT >, is_constructible< DT, std::initializer_list< U > &, Args &&... > >, int > = 0>
DT & any::emplace ( std::initializer_list< U > ilist,
Args &&... args )
inline

使用初始化列表就地构造

模板参数
T值类型
U初始化列表元素类型
Args参数类型
参数
ilist初始化列表
args构造参数
返回
构造的值的引用

在文件 utility/any.hpp368 行定义.

引用了 forward().

◆ has_value()

NEFORCE_NODISCARD bool any::has_value ( ) const
inlinenoexcept

检查是否包含值

返回
是否包含值

在文件 utility/any.hpp387 行定义.

被这些函数引用 reset().

◆ operator=() [1/3]

any & any::operator= ( any && other)
noexcept

移动赋值运算符

参数
other源any对象
返回
当前对象的引用

引用了 any().

◆ operator=() [2/3]

any & any::operator= ( const any & other)
inline

复制赋值运算符

参数
other源any对象
返回
当前对象的引用

在文件 utility/any.hpp262 行定义.

引用了 any().

◆ operator=() [3/3]

template<typename T, typename VT = decay_t<T>, enable_if_t<!is_same_v< VT, any > &&is_copy_constructible_v< VT >, int > = 0>
any & any::operator= ( T && value)
inline

从值赋值

模板参数
T值类型
参数
value要存储的值
返回
当前对象的引用

在文件 utility/any.hpp301 行定义.

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

◆ swap()

void any::swap ( any & rhs)
noexcept

交换两个any对象

参数
rhs要交换的any对象

引用了 any(), is_constructible_v , 以及 swap().

被这些函数引用 swap().

◆ type()

NEFORCE_NODISCARD const std::type_info & any::type ( ) const
noexcept

获取存储值的类型信息

返回
类型信息引用

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