首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::any

Defined in header <any>

class any;

(since C++17)

全班any描述任何类型的单个值的类型安全容器。

1%29类对象any存储满足构造函数要求或为空的任何类型的实例,这称为国家全班any对象。存储的实例称为包含的对象。如果两种状态都是空的,或者两者都是空的,如果包含的对象是等效的,则它们是等效的。

2%29非会员any_cast函数提供对所包含对象的类型安全访问。

我们鼓励实现避免对小对象进行动态分配,但是这样的优化可能只适用于以下类型:std::is_nothrow_move_constructible回报true...

成员函数

(constructor)

constructs an any object (public member function)

operator=

assigns an any object (public member function)

(destructor)

destroys an any object (public member function)

修饰语者

修改包含的对象,直接构造新对象%28公共成员函数%29

重置销毁包含的对象%28公共成员函数%29

交换交换2任何对象%28公共成员函数%29

观察员

有[医]值检查对象是否持有值%28公共成员函数%29

类型返回包含的值%28公共成员函数%29的类型

非会员职能

std::swap(std::any) (C++17)

specializes the std::swap algorithm (function)

any_cast (C++17)

type-safe access to the contained object (function template)

make_any (C++17)

creates an any object (function template)

帮助者类

bad_any_cast (C++17)

exception thrown by the value-returning forms of any_cast on a type mismatch (class)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券