2021年最新整理,500个c++11/14/17/20/23的新特性代码案例,包含lambda匿名函数,右值引用,auto,coroutine库,synchronization库,持续更新中......
- is_void
- is_integral
- is_floating_point
- is_array
- is_enum
- is_union
- is_class
- is_function
- is_pointer
- is_lvalue_reference
- is_rvalue_reference
- is_member_object_pointer
- is_member_function_pointer
- is_const
- is_volatile
- is_trivial
- is_trivially_copyable
- is_standard_layout
- is_literal_type
- is_empty
- is_polymorphic
- is_abstract
- is_signed
- is_unsigned
- is_constructible
- is_trivially_constructible
- is_nothrow_constructible
- is_default_constructible
- is_trivially_default_constructible
- is_nothrow_default_constructible
- is_copy_constructible
- is_trivially_copy_constructible
- is_nothrow_copy_constructible
- is_move_constructible
- is_trivially_move_constructible
- is_nothrow_move_constructible
- is_assignable
- is_trivially_assignable
- is_nothrow_assignable
- is_copy_assignable
- is_trivially_copy_assignable
- is_nothrow_copy_assignable
- is_move_assignable
- is_trivially_move_assignable
- is_nothrow_move_assignable
- is_destructible
- is_trivially_destructible
- is_nothrow_destructible
- has_virtual_destructor
- std::hash<std::string>
- std::hash<std::u16string>
- std::hash<std::u32string>
- std::hash<std::wstring>
- std::hash<std::error_code>
- std::hash<std::bitset>
- std::hash<std::type_index>
- std::hash<std::vector<bool>>
- std::atomic<bool>
- std::atomic<char>
- std::atomic<signed char>
- std::atomic<unsigned char>
- std::atomic<short>
- std::atomic<unsigned short>
- std::atomic<int>
- std::atomic<unsigned int>
- std::atomic<long>
- std::atomic<unsigned long>
- std::atomic<long long>
- std::atomic<unsigned long long>
- std::atomic<char8_t>
- std::atomic<char16_t>
- std::atomic<char32_t>
- std::atomic<wchar_t>
- std::atomic<std::int8_t>
- std::atomic<std::uint8_t>
- std::atomic<std::int16_t>
- std::atomic<std::uint16_t>
- std::atomic<std::int32_t>
- std::atomic<std::uint32_t>
- std::atomic<std::int64_t>
- std::atomic<std::uint64_t>
- std::atomic<std::int_least8_t>
- std::atomic<std::uint_least8_t>
- std::atomic<std::int_least16_t>
- std::atomic<std::uint_least16_t>
- std::atomic<std::int_least32_t>
- std::atomic<std::uint_least32_t>
- std::atomic<std::int_least64_t>
- std::atomic<std::uint_least64_t>
- std::atomic<std::int_fast8_t>
- std::atomic<std::uint_fast8_t>
- std::atomic<std::int_fast16_t>
- std::atomic<std::uint_fast16_t>
- std::atomic<std::int_fast32_t>
- std::atomic<std::uint_fast32_t>
- std::atomic<std::int_fast64_t>
- std::atomic<std::uint_fast64_t>
- std::atomic<std::intptr_t>
- std::atomic<std::uintptr_t>
- std::atomic<std::size_t>/a>
- std::atomic<std::ptrdiff_t>
- std::atomic<std::intmax_t>
- std::atomic<std::uintmax_t>
- std::thread
- std::mutex
- std::lock
- std::call_once
- std::atomic
- std::condition_variable
- async
- volatile
- std::future
- std::thread_local
- std::exception_ptr
- std::make_exception_ptr
- std::current_exception
- std::rethrow_exception
- std::nested_exception
- std::throw_with_nested
- std::rethrow_if_nested
- std::error_category
- std::generic_category
- std::error_condition
- std::errc
- std::error_code
- std::system_error
-
语法:__pragma(字符串字面量)
- _Pragma运算符
-
语法:static_assert(常量表达式,"提示字符串")
- static assert
- as_const(获得到其实参的 const 引用)
- in_place(原位构造标签)
- in_place_type(原位构造标签)
- in_place_index(原位构造标签)
- in_place_t(原位构造标签)
- in_place_type_t(原位构造标签)
- in_place_index_t(原位构造标签)
- optional(可能或可能不保有一个对象的包装器)
- make_optional(创建一个 optional 对象)
- std::swap(std::optional)(特化 std::swap 算法)
- std::hashstd::optional(特化 std::hash 算法)
- nullopt_t(带未初始化状态的 optional 类型的指示器)
- bad_optional_access(指示进行了到不含值的 optional 的有检查访问的异常)
- nullopt(nullopt_t 类型对象)
- in_place(原位构造标签)
- in_place_type(原位构造标签)
- in_place_index(原位构造标签)
- in_place_t(原位构造标签)
- in_place_type_t(原位构造标签)
- in_place_index_t(原位构造标签)
- variant(类型安全的可辨识联合体)
- visit(以一或多个 variant 所保有的各实参调用所提供的函数对象)
- holds_alternative(检查某个 variant 是否当前持有某个给定类型)
- std::get(std::variant)(以给定索引或类型(若类型唯一)读取 variant 的值,错误时抛出异常)
- get_if(以给定索引或类型(若其唯一),获得指向被指向的 variant 的值的指针,错误时返回空指针)
- std::swap(std::variant)(特化 std::swap 算法)
- monostate(用作非可默认构造类型的 variant 的首个可选项的占位符类型)
- bad_variant_access(非法地访问 variant 的值时抛出的异常)
- variant_size(在编译时获得 variant 可选项列表的大小)
- variant_size_v(在编译时获得 variant 可选项列表的大小)
- variant_alternative(在编译时获得以其下标指定的可选项的类型)
- variant_alternative_t(在编译时获得以其下标指定的可选项的类型)
- std::hash<std::variant>(特化 std::hash 算法)
- variant_npos(非法状态的 variant 的下标)
- any(可保有任何可复制构造 (CopyConstructible) 类型的实例的对象)
- std::swap(std::any)(特化 std::swap 算法)
- any_cast(对被容纳对象的类型安全访问)
- make_any(创建 any 对象)
- bad_any_cast(当类型不匹配时按值返回形式的 any_cast 所抛出的异常)
- to_chars(转换整数或浮点值到字符序列象)
- from_chars(转换字符序列到整数或浮点值)
- chars_format(指定 std::to_chars 和 std::from_chars 所用的格式)
- insert_or_assign(插入元素,或若键已存在则赋值给当前元素)
- try_emplace(若键不存在则原位插入,若键存在则不做任何事)
- extract(从另一容器释出结点)
- merge(从另一容器接合结点)
- insert_or_assign(插入元素,或若键已存在则赋值给当前元素)
- try_emplace(若键不存在则原位插入,若键存在则不做任何事)
- extract(从另一容器释出结点)
- merge(从另一容器接合结点)
-
is_pointer_interconvertible_base_of(检查一个类型是否为另一类型的指针可互转换(起始)基类)
-
is_pointer_interconvertible_with_class(检查一个类型的对象是否与该类型的指定子对象指针可互转换)
- coroutine_traits(用于发现协程承诺类型的特征类型)
- coroutine_handle(用于指代暂停或执行的协程)
- noop_coroutine(创建在等待或销毁时无操作的协程柄)
- noop_coroutine_promise(用于无可观察作用的协程)
- noop_coroutine_handle(std::coroutine_handle<std::noop_coroutine_promise> ,有意用于指代无操作协程)
- suspend_never(指示 await 表达式应该决不暂停)
- suspend_always(指示 await 表达式应该始终暂停)
- std::coroutine_traits
- std::coroutine_handle
- three_way_comparable(指定运算符 <=> 在给定类型上产生一致的结果)
- three_way_comparable_with(指定运算符 <=> 在给定类型上产生一致的结果)
- partial_ordering(三路比较的结果类型,支持所有 6 种运算符,不可替换,并允许不可比较的值)
- weak_ordering(三路比较的结果类型,支持所有 6 种运算符且不可替换)
- strong_ordering(三路比较的结果类型,支持所有 6 种运算符且可替换)
- is_eq(具名比较函数)
- is_neq(具名比较函数)
- is_lt(具名比较函数)
- is_lteq(具名比较函数)
- is_gt(具名比较函数)
- is_gteq(具名比较函数)
- compare_three_way(实现 x <=> y 的函数对象)
- compare_three_way_result(获得三路比较运算符 <=> 在给定类型上的结果)
- common_comparison_category(给定的全部类型都能转换到的最强比较类别)
- strong_order(进行三路比较并产生 std::strong_ordering 类型结果)
- weak_order(进行三路比较并产生 std::weak_ordering 类型结果)
- partial_order(进行三路比较并产生 std::partial_ordering 类型结果)
- compare_strong_order_fallback(进行三路比较并产生 std::strong_ordering 类型的结果,即使 operator<=> 不可用)
- compare_weak_order_fallback(进行三路比较并产生 std::weak_ordering 类型的结果,即使 operator<=> 不可用)
- compare_partial_order_fallback(进行三路比较并产生 std::partial_ordering 类型的结果,即使 operator<=> 不可用
- cmp_equal(比较二个整数值,而无转换所致的值更改)
- cmp_not_equal(比较二个整数值,而无转换所致的值更改)
- cmp_less(比较二个整数值,而无转换所致的值更改)
- cmp_less_equal(比较二个整数值,而无转换所致的值更改)
- cmp_greater_equal(比较二个整数值,而无转换所致的值更改)
- in_range(检查整数值是否在给定整数类型的范围内)
- uninitialized_move(移动一个范围的对象到未初始化的内存区域)
- uninitialized_move_n(移动一定数量对象到未初始化内存区域)
- uninitialized_default_construct(在范围所定义的未初始化的内存区域以默认初始化构造对象)
- uninitialized_default_construct_n(在起始和计数所定义的未初始化内存区域用默认初始化构造对象)
- uninitialized_value_construct(在范围所定义的未初始化内存中用值初始化构造对象)
- uninitialized_value_construct_n(在起始和计数所定义的未初始化内存区域以值初始化构造对象)
- destroy_at(销毁在给定地址的对象)
- destroy(销毁一个范围中的对象)
- destroy_n(销毁范围中一定数量的对象)
- polymorphic_allocator(以 std::memory_resource 构造,支持基于它的运行时多态的分配器)
- memory_resource(一个抽象接口,用于各种封装内存资源的类)
- new_delete_resource(返回一个静态的程序范围 std::pmr::memory_resource,它使用全局 operator new 与 operator delete 分配和解分配内存
- null_memory_resource(返回一个不进行任何分配的静态 std::pmr::memory_resource)
- get_default_resource(获取缺省 std::pmr::memory_resource)
- set_default_resource(设置缺省 std::pmr::memory_resource)
- pool_options(一组池资源的构造函数选项)
- synchronized_pool_resource(线程安全的 std::pmr::memory_resource,用于管理具有不同块大小的池中的分配)
- unsynchronized_pool_resource(线程不安全的 std::pmr::memory_resource,用于管理具有不同块大小的池中的分配)
- monotonic_buffer_resource(一种特殊用途的 std::pmr::memory_resource,仅在资源被销毁时才释放所分配内存)
- same_as(指定一个类型与另一类型相同)
- derived_from(指定一个类型派生自另一类型)
- convertible_to(指定一个类型能隐式转换成另一类型)
- common_reference_with(指定两个类型共有一个公共引用类型)
- common_with(指定两个类型共有一个公共类型)
- integral(指定类型为整型类型)
- signed_integral(指定类型为有符号的整型类型)
- unsigned_integral(指定类型为无符号的整型类型)
- floating_point(指定类型为浮点类型)
- assignable_from(指定一个类型能从另一类型赋值)
- swappable(指定一个类型能进行交换,或两个类型能彼此交换)
- swappable_with(指定一个类型能进行交换,或两个类型能彼此交换)
- destructible(指定能销毁该类型的对象)
- constructible_from(指定该类型的变量能从一组实参类型进行构造,或绑定到一组实参类型)
- default_initializable(指定能默认构造一个类型的对象)
- move_constructible(指定能移动构造一个类型的对象)
- copy_constructible(指定能复制构造和移动构造一个类型的对象)
- boolean-testable(指定能用于布尔语境的类型)
- equality_comparable(指定运算符 == 为等价关系)
- equality_comparable_with(指定运算符 == 为等价关系)
- totally_ordered(指定比较运算符在该类型上产生全序)
- totally_ordered_with(指定比较运算符在该类型上产生全序)
- movable(指定能移动及交换一个类型的对象)
- copyable(指定能复制、移动及交换一个类型的对象)
- semiregular(指定能赋值、移动、交换及默认构造一个类型的对象)
- regular(指定类型为正则,即它既为 semiregular 亦为 equality_comparable)
- invocable(指定能以给定的一组实参类型调用的可调用类型)
- regular_invocable(指定能以给定的一组实参类型调用的可调用类型)
- predicate(指定可调用类型为布尔谓词)
- relation(指定可调用类型为二元关系)
- equivalence_relation(指定 relation 施加等价关系)
- strict_weak_order(指定一个 relation 所强加的是严格弱序)
-
uses_allocator_construction_args(准备匹配给定类型所要求的使用分配器构造的口味的参数列表)
-
uninitialized_construct_using_allocator(以使用分配器构造的手段在指定的内存位置创建给定类型的对象)
-
ranges::uninitialized_default_construct(在范围所定义的未初始化的内存区域以默认初始化构造对象)
-
ranges::uninitialized_default_construct_n(在起始与计数所定义的未初始化的内存区域以默认初始化构造对象)
-
ranges::uninitialized_value_construct(在范围所定义的未初始化的内存区域以值初始化构造对象)
-
ranges::uninitialized_value_construct_n(在起始与计数所定义的未初始化的内存区域以值初始化构造对象)
- is_clock(确定类型是否为时钟 (Clock))
- is_clock_v(确定类型是否为时钟 (Clock))
- utc_clock(协调世界时 (UTC) 的时钟 (Clock))
- tai_clock(国际原子时 (TAI) 的时钟 (Clock))
- gps_clock(GPS 时间的时钟 (Clock))
- file_clock(用于文件时间的时钟 (Clock))
- local_t(表示本地时间的伪时钟)
- clock_time_conversion(定义如何转换一个时钟的时间点为另一个的特性类)
- clock_cast(转换一个时钟的时间点为另一个)
- time_of_day(表示一日中的时间)
- is_am(在 12 时和 24 时格式当天时刻之间翻译)
- is_pm(在 12 时和 24 时格式当天时刻之间翻译)
- make12(在 12 时和 24 时格式当天时刻之间翻译)
- make24(在 12 时和 24 时格式当天时刻之间翻译)
- last_spec(指示一个月中最后日期或星期的标签类)
- day(表示月之日期)
- month(表示年之月份)
- year(表示格里高利历中的年)
- weekday(表示格里高利历中星期之日)
- weekday_indexed(表示月份的第 n 个 weekday)
- weekday_last(表示月份的最后一个 weekday)
- month_day(表示特定 month 的特定 day)
- month_day_last(表示特定 month 的最后一日)
- month_weekday(表示特定 month 的第 n 个 weekday)
- month_weekday_last(表示特定 month 的最后一个 weekday)
- year_month(表示特定 year 的特定 month)
- year_month_day(表示特定的 year 、 month 和 day)
- year_month_day_last(表示特定 year 和 month 的最后一日)
- year_month_weekday(表示特定 year 和 month 的第 n 个 weekday)
- year_month_weekday_last(表示特定 year 和 month 的最后一个 weekday)
- operator/(创建格里高利历日期的约定语法)
- tzdb(描述 IANA 时区数据库的副本)
- tzdb_list(表示 tzdb 的链表)
- get_tzdb(访问和控制全球时区数据库信息)
- get_tzdb_list(访问和控制全球时区数据库信息)
- reload_tzdb(访问和控制全球时区数据库信息)
- remote_version(访问和控制全球时区数据库信息)
- locate_zone(定位基于其名称的 time_zone)
- current_zone(返回当前的 time_zone)
- time_zone(表示时区)
- sys_info(表示在特定时间点的关于时区的信息)
- local_info(表示关于从本地时间转换到 UNIX 时间的信息)
- choose(选择应如何解析歧义的本地时间)
- zoned_traits(zoned_time 所用的时区指针的特性类)
- zoned_time(表示时区和时间点)
- leap_second(含有关于插入闰秒的信息)
- time_zone_link(表示时区的替用名)
- nonexistent_local_time(抛出以报告本地时间不存在的异常)
- ambiguous_local_time(抛出以报告本地时间有歧义的异常)
- parse(从流分析 chrono 对象)
- begin(返回指向起始的迭代器)
- end(返回指向末尾的迭代器)
- rbegin(返回指向起始的逆向迭代器)
- rend(返回指向末尾的逆向迭代器)
- front(访问第一个元素)
- back(访问最后一个元素)
- dynamic_extent(size_t 类型常量,指明 span 拥有动态长度)
- indirectly_readable(指定类型通过应用运算符 * 可读)
- indirectly_writable(指定可向迭代器所引用的对象写入值)
- weakly_incrementable(指定 semiregular 类型能以前后自增运算符自增)
- incrementable(指定 weakly_incrementable 类型上的自增操作保持相等性,而且该类型为 equality_comparable)
- input_or_output_iterator(指定该类型对象可以自增且可以解引用)
- sentinel_for(指定类型为某个 input_or_output_iterator 类型的哨位类型)
- sized_sentinel_for(指定可对一个迭代器和一个哨位应用 - 运算符,以在常数时间计算其距离)
- input_iterator(指定类型为输入迭代器,即可读取其所引用的值,且可前/后自增)
- output_iterator(指定类型为给定的值类型的输出迭代器,即可向其写入该类型的值,且可前/后自增)
- forward_iterator(指定 input_iterator 为向前迭代器,支持相等比较与多趟操作)
- bidirectional_iterator(指定 forward_iterator 为双向迭代器,支持向后移动)
- random_access_iterator(指定 bidirectional_iterator 为随机访问迭代器,支持常数时间内的前进和下标访问)
- contiguous_iterator(指定 random_access_iterator 为连续迭代器,指代内存中连续相接的元素)
- indirectly_readable_traits(计算 indirectly_readable 类型的值类型)
- iter_value_t(计算迭代器的关联类型)
- iter_reference_t(计算迭代器的关联类型)
- iter_difference_t(计算迭代器的关联类型)
- iter_rvalue_reference_t(计算迭代器的关联类型)
- iter_common_reference_t(计算迭代器的关联类型)
- iterator_traits(为迭代器各项性质提供统一接口)
- input_iterator_tag(用于指示迭代器类别的空类类型)
- output_iterator_tag(用于指示迭代器类别的空类类型)
- forward_iterator_tag(用于指示迭代器类别的空类类型)
- bidirectional_iterator_tag(用于指示迭代器类别的空类类型)
- random_access_iterator_tag(用于指示迭代器类别的空类类型)
- contiguous_iterator_tag(用于指示迭代器类别的空类类型)
- indirectly_readable(指定类型通过应用运算符 * 可读)
- indirectly_writable(指定可向迭代器所引用的对象写入值)
- weakly_incrementable(指定 semiregular 类型能以前后自增运算符自增)
- incrementable(指定 weakly_incrementable 类型上的自增操作保持相等性,而且该类型为 equality_comparable)
- input_or_output_iterator(指定该类型对象可以自增且可以解引用)
- sentinel_for(指定类型为某个 input_or_output_iterator 类型的哨位类型)
- sized_sentinel_for(指定可对一个迭代器和一个哨位应用 - 运算符,以在常数时间计算其距离)
- input_iterator(指定类型为输入迭代器,即可读取其所引用的值,且可前/后自增)
- output_iterator(指定类型为给定的值类型的输出迭代器,即可向其写入该类型的值,且可前/后自增)
- forward_iterator(指定 input_iterator 为向前迭代器,支持相等比较与多趟操作)
- bidirectional_iterator(指定 forward_iterator 为双向迭代器,支持向后移动)
- random_access_iterator(指定 bidirectional_iterator 为随机访问迭代器,支持常数时间内的前进和下标访问)
- contiguous_iterator(指定 random_access_iterator 为连续迭代器,指代内存中连续相接的元素)
- incrementable_traits(计算 weakly_incrementable 类型的差类型)
- indirectly_readable_traits(计算 indirectly_readable 类型的值类型)
- iter_value_t(计算迭代器的关联类型)
- iter_reference_t(计算迭代器的关联类型)
- iter_difference_t(计算迭代器的关联类型)
- iter_rvalue_reference_t(计算迭代器的关联类型)
- iter_common_reference_t(计算迭代器的关联类型)
- iterator_traits(为迭代器各项性质提供统一接口)
- input_iterator_tag(用于指示迭代器类别的空类类型)
- output_iterator_tag(用于指示迭代器类别的空类类型)
- forward_iterator_tag(用于指示迭代器类别的空类类型)
- bidirectional_iterator_tag(用于指示迭代器类别的空类类型)
- random_access_iterator_tag(用于指示迭代器类别的空类类型)
- contiguous_iterator_tag(用于指示迭代器类别的空类类型)
- indirectly_unary_invocable(指定可调用类型能以解引用某个 indirectly_readable 类型的结果进行调用)
- indirectly_regular_unary_invocable(指定可调用类型能以解引用某个 indirectly_readable 类型的结果进行调用)
- indirect_unary_predicate(指定可调用类型,在以解引用一个 indirectly_readable 类型的结果进行调用时,满足 predicate)
- indirect_binary_predicate(指定可调用类型,在以解引用两个 indirectly_readable 类型的结果进行调用时,满足 predicate)
- indirect_equivalence_relation(指定可调用类型,在以解引用两个 indirectly_readable 类型的结果进行调用时,满足 equivalence_relation)
- indirect_strict_weak_order(指定可调用类型,在以解引用两个 indirectly_readable 类型的结果进行调用时,满足 strict_weak_order)
- indirectly_movable(指定可从 indirectly_readable 类型移动值给 indirectly_writable 类型)
- indirectly_movable_storable(指定可从 indirectly_readable 类型移动值给 indirectly_writable 类型,且该移动可以通过中间对象进行)
- indirectly_copyable(指定可从 indirectly_readable 类型复制值给 indirectly_writable 类型)
- indirectly_copyable_storable(指定可从 indirectly_readable 类型复制值给 indirectly_writable 类型,且该复制可以通过中间对象进行)
- indirectly_swappable(指定能交换两个 indirectly_readable 类型所引用的值)
- indirectly_comparable(指定能比较两个 indirectly_readable 类型所引用的值)
- permutable(指定在原位重排元素的算法的共用要求)
- mergeable(指定通过复制元素将已排序序列归并到输出序列中的算法的要求)
- sortable(指定重排序列为有序序列的算法的共用要求)
- indirect_result_t(计算在解引用某组 indirectly_readable 类型的结果上调用可调用对象的结果)
- projected(用于对接受投影的算法指定约束的辅助模板)
- move_sentinel(用于 std::move_iterator 的哨位适配器)
- common_iterator(适配一个迭代器类型及其哨位为一个公共迭代器类型)
- default_sentinel_t(用于知晓其边界的迭代器的默认哨位)
- counted_iterator(对到范围结尾距离进行跟踪的迭代器适配器)
- unreachable_sentinel_t(始终与任何 weakly_incrementable 类型比较都不相等的哨位)
- ranges::advance(令迭代器前进给定的距离或到给定的边界)
- ranges::distance(返回迭代器与哨位间的距离,或范围起始与结尾间的距离)
- ranges::next(自增迭代器给定的距离或到边界)
- ranges::prev(自减迭代器给定的距离或到边界)
- ranges::begin(返回指向范围起始的迭代器)
- ranges::cbegin(返回指向只读范围起始的迭代器)
- ranges::end(返回指示范围结尾的哨位)
- ranges::cend(返回指示只读范围结尾的哨位)
- ranges::rbegin(返回指向范围的逆向迭代器)
- ranges::crbegin(返回指向只读范围的逆向迭代器)
- ranges::rend(返回指向范围的逆向尾迭代器)
- ranges::crend(返回指向只读范围的逆向尾迭代器)
- ranges::size(获得能在常数时间内计算大小的范围的大小)
- ranges::ssize(获得能在常数时间内计算大小的范围的大小,并将它转换成有符号整数)
- ranges::empty(检查范围是否为空)
- ranges::data(获得指向连续范围的起始的指针)
- ranges::cdata(获得指向只读连续范围的起始的指针)