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

Utility library

C++包括多种实用程序库,它们提供的功能范围从位计数到部分函数应用这些图书馆大致可分为两类:

  • 语言支持库,以及
  • 普通图书馆。

语言支持

语言支持库提供了与语言特性密切交互的类和函数,并支持常见的语言习语。

类型支撑

基本类型%28例如。std::size_t,,,std::nullptr_t%29,RTTI%28等。std::type_info29%,类型性状%28等。std::is_integral,,,std::rank29%。

动态内存管理

智能指针%28例如。std::shared_ptr%29,分配程序%28等。std::allocatorstd::memory_resource%29,C型内存管理%28例如。std::malloc29%。

错误处理

例外%28例如std::exception,,,std::logic_error%29,断言%28等。assert29%。

初始程序列表

initializer_list (C++11)

allows the use of initializer list syntax to initialize non-aggregate types (class template)

变分函数

支持任意数目参数%28的函数。va_start,,,va_arg,,,va_end29%。

通用公用事业

程序实用程序

终止%28等std::abort,,,std::atexit%29,环境%28等。std::system%29,信号%28等。std::raise29%。

日期和时间

时间跟踪%28例如。std::chrono::time_point,,,std::chrono::duration%29,C样式日期和时间%28例如。std::time,,,std::clock29%。

比特集

bitset

implements constant length bit array (class)

功能对象

部分功能应用%28。std::bind%29及相关实用程序:绑定实用程序,如std::refstd::placeholders,多态函数包装器:std::function,预定义函子%28等。std::plus,,,std::equal_to%29,功能转换器的方法std::mem_fn...

可选、变式和任何

在标头中定义<optional>

*。

可选%28,因为C++17%29是一个包装器,它可能包含对象%28类模板,也可能不包含对象

在标头中定义<variant>

变体%28自C++17%29 a类型安全识别联合%28类模板%29

在标头中定义<any>

任何%28自C++17%29个对象,这些对象包含任何CopyConstrucable类型的实例。28级%29

在标头中定义<utility>

在[医]安放[医]位置[医]键入[医]位置[医]索引[医]位置[医]t in[医]位置[医]类型[医]t in[医]位置[医]指数[医]T%28C++17%29现场施工标签%28类模板%29

对和元组

pair

implements binary tuple, i.e. a pair of values (class template)

tuple (C++11)

implements fixed size container, which holds elements of possibly different types (class template)

apply (C++17)

calls a function with a tuple of arguments (function template)

make_from_tuple (C++17)

Construct an object with a tuple of arguments (function template)

piecewise_construct_t (C++11)

tag type used to select correct function overload for piecewise construction (class)

piecewise_construct (C++11)

an object of type piecewise_construct_t used to disambiguate functions for piecewise construction (constant)

integer_sequence (C++14)

implements compile-time sequence of integers (class template)

交换、前进和移动

swap

swaps the values of two objects (function template)

exchange (C++14)

replaces the argument with a new value and returns its previous value (function template)

forward (C++11)

forwards a function argument (function template)

move (C++11)

obtains an rvalue reference (function template)

move_if_noexcept (C++11)

obtains an rvalue reference if the move constructor does not throw (function template)

类型操作

在标头中定义<utility>

*。

Decval%28C++11%29获得对其参数的引用,以便用于未评估的上下文%28函数模板%29

如[医]Const%28C++17%29获得对其参数%28函数模板%29的引用

在标头中定义<new>

清洗%28C++17%29指针优化屏障%28功能模板%29

关系算子

在标头中定义<utility>

*。

在命名空间std::rel中定义[医]行动部

运算符%21=运算符>运算符<=操作符>=自动生成比较操作符,基于用户定义的运算符==和运算符<%28函数模板%29。

初等字符串转换

除了复杂的依赖于地区的解析器和格式化程序之外,C++I/O图书馆C I/O图书馆,C++串转换器,和C串转换器,标题<utility>为算术类型提供重量轻、与地区无关、不分配、不抛出、ASCII专用的解析器和格式化器.

to_chars (C++17)

converts an integer or floating-point value to a character sequence (function)

from_chars (C++17)

converts a character sequence to an integer or floating-point value (function)

chars_format (C++17)

specifies formatting for std::to_chars and std::from_chars (enum)

散列支持

hash (C++11)

hash function object (class template)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券