库特性测试宏 (C++20 起)

来自cppreference.com
< cpp‎ | utility


 
 
 

如果包含 <version> 或下表中指定的标头之一,那么就会定义对应的宏。

宏名标头 独立 
__cpp_lib_adaptor_iterator_pair_constructor202106L<stack> <queue>
__cpp_lib_addressof_constexpr201603L<memory>
__cpp_lib_algorithm_default_value_type202403L<algorithm> <ranges> <string> <deque> <list> <forward_list> <vector>
__cpp_lib_algorithm_iterator_requirements202207L<algorithm> <numeric> <memory>
__cpp_lib_aligned_accessor202411L<mdspan>
__cpp_lib_allocate_at_least202302L<memory>
__cpp_lib_allocator_traits_is_always_equal201411L<memory> <scoped_allocator> <string> <deque> <forward_list> <list> <vector> <map> <set> <unordered_map> <unordered_set>
__cpp_lib_any201606L<any>
__cpp_lib_apply201603L<tuple>
__cpp_lib_array_constexpr201811L<iterator> <array>
__cpp_lib_as_const201510L<utility>
__cpp_lib_associative_heterogeneous_erasure202110L<map> <set> <unordered_map> <unordered_set>
__cpp_lib_associative_heterogeneous_insertion202306L<map> <set> <unordered_map> <unordered_set>
__cpp_lib_assume_aligned201811L<memory>
__cpp_lib_atomic_flag_test201907L<atomic>
__cpp_lib_atomic_float201711L<atomic>
__cpp_lib_atomic_is_always_lock_free201603L<atomic>
__cpp_lib_atomic_lock_free_type_aliases201907L<atomic>
__cpp_lib_atomic_min_max202403L<atomic>
__cpp_lib_atomic_ref202411L<atomic>
__cpp_lib_atomic_shared_ptr201711L<memory>
__cpp_lib_atomic_value_initialization201911L<atomic> <memory>
__cpp_lib_atomic_wait201907L<atomic>
__cpp_lib_barrier202302L<barrier>
__cpp_lib_bind_back202306L<functional>
__cpp_lib_bind_front202306L<functional>
__cpp_lib_bit_cast201806L<bit>
__cpp_lib_bitops201907L<bit>
__cpp_lib_bitset202306L<bitset>
__cpp_lib_bool_constant201505L<type_traits>
__cpp_lib_bounded_array_traits201902L<type_traits>
__cpp_lib_boyer_moore_searcher201603L<functional>
__cpp_lib_byte201603L<cstddef>
__cpp_lib_byteswap202110L<bit>
__cpp_lib_char8_t201907L<atomic> <filesystem> <istream> <limits> <locale> <ostream> <string> <string_view>
__cpp_lib_chrono202306L<chrono>
__cpp_lib_chrono_udls201304L<chrono>
__cpp_lib_clamp201603L<algorithm>
__cpp_lib_common_reference202302L<type_traits>
__cpp_lib_common_reference_wrapper202302L<functional>
__cpp_lib_complex_udls201309L<complex>
__cpp_lib_concepts202207L<concepts> <compare>
__cpp_lib_constexpr_algorithms202306L<algorithm> <utility>
__cpp_lib_constexpr_atomic202411L<atomic>
__cpp_lib_constexpr_bitset202207L<bitset>
__cpp_lib_constexpr_charconv202207L<charconv>
__cpp_lib_constexpr_cmath202306L<cmath> <cstdlib>
__cpp_lib_constexpr_complex202306L<complex>
__cpp_lib_constexpr_dynamic_alloc201907L<memory>
__cpp_lib_constexpr_exceptions202411L<exception>
__cpp_lib_constexpr_functional201907L<functional>
__cpp_lib_constexpr_inplace_vector202502L<inplace_vector>
__cpp_lib_constexpr_iterator201811L<iterator>
__cpp_lib_constexpr_memory202202L<memory>
__cpp_lib_constexpr_new202406L<new>
__cpp_lib_constexpr_numeric201911L<numeric>
__cpp_lib_constexpr_string201907L<string>
__cpp_lib_constexpr_string_view201811L<string_view>
__cpp_lib_constexpr_tuple201811L<tuple>
__cpp_lib_constexpr_typeinfo202106L<typeinfo>
__cpp_lib_constexpr_utility201811L<utility>
__cpp_lib_constexpr_vector201907L<vector>
__cpp_lib_constrained_equality202411L<utility> <tuple> <optional> <variant> <expected>
__cpp_lib_containers_ranges202202L<vector> <list> <forward_list> <map> <set> <unordered_map> <unordered_set> <deque> <queue> <stack> <string>
__cpp_lib_copyable_function202306L<functional>
__cpp_lib_coroutine201902L<coroutine>
__cpp_lib_debugging202403L<debugging>
__cpp_lib_destroying_delete201806L<new>
__cpp_lib_enable_shared_from_this201603L<memory>
__cpp_lib_endian201907L<bit>
__cpp_lib_erase_if202002L<string> <deque> <forward_list> <list> <vector> <map> <set> <unordered_map> <unordered_set>
__cpp_lib_exchange_function201304L<utility>
__cpp_lib_execution201902L<execution>
__cpp_lib_expected202211L<expected>
__cpp_lib_filesystem201703L<filesystem>
__cpp_lib_flat_map202207L<flat_map>
__cpp_lib_flat_set202207L<flat_set>
__cpp_lib_format202311L<format>
__cpp_lib_format_ranges202207L<format>
__cpp_lib_format_path202403L<filesystem>
__cpp_lib_format_uchar202311L<format>
__cpp_lib_formatters202302L<stacktrace> <thread>
__cpp_lib_forward_like202207L<utility>
__cpp_lib_freestanding_algorithm202311L<algorithm>
__cpp_lib_freestanding_array202311L<array>
__cpp_lib_freestanding_char_traits202306L<string>
__cpp_lib_freestanding_charconv202306L<charconv>
__cpp_lib_freestanding_cstdlib202306L<cstdlib> <cmath>
__cpp_lib_freestanding_cstring202311L<cstring>
__cpp_lib_freestanding_cwchar202306L<cwchar>
__cpp_lib_freestanding_errc202306L<cerrno> <system_error>
__cpp_lib_freestanding_expected202311L<expected>
__cpp_lib_freestanding_feature_test_macros202306L
__cpp_lib_freestanding_functional202306L<functional>
__cpp_lib_freestanding_iterator202306L<iterator>
__cpp_lib_freestanding_mdspan202311L<mdspan>
__cpp_lib_freestanding_memory202306L<memory>
__cpp_lib_freestanding_numeric202311L<numeric>
__cpp_lib_freestanding_optional202311L<optional>
__cpp_lib_freestanding_ranges202306L<ranges>
__cpp_lib_freestanding_ratio202306L<ratio>
__cpp_lib_freestanding_string_view202311L<string_view>
__cpp_lib_freestanding_tuple202306L<tuple>
__cpp_lib_freestanding_utility202306L<utility>
__cpp_lib_freestanding_variant202311L<variant>
__cpp_lib_fstream_native_handle202306L<fstream>
__cpp_lib_function_ref202306L<functional>
__cpp_lib_gcd_lcm201606L<numeric>
__cpp_lib_generator202207L<generator>
__cpp_lib_generic_associative_lookup201304L<map> <set>
__cpp_lib_generic_unordered_lookup201811L<unordered_map> <unordered_set>
__cpp_lib_hardware_interference_size201703L<new>
__cpp_lib_has_unique_object_representations201606L<type_traits>
__cpp_lib_hazard_pointer202306L<hazard_pointer>
__cpp_lib_hypot201603L<cmath>
__cpp_lib_incomplete_container_elements201505L<forward_list> <list> <vector>
__cpp_lib_inplace_vector202406L<inplace_vector>
__cpp_lib_int_pow2202002L<bit>
__cpp_lib_integer_comparison_functions202002L<utility>
__cpp_lib_integer_sequence201304L<utility>
__cpp_lib_integral_constant_callable201304L<type_traits>
__cpp_lib_interpolate201902L<cmath> <numeric>
__cpp_lib_invoke201411L<functional>
__cpp_lib_invoke_r202106L<functional>
__cpp_lib_ios_noreplace202207L<ios>
__cpp_lib_is_aggregate201703L<type_traits>
__cpp_lib_is_constant_evaluated201811L<type_traits>
__cpp_lib_is_final201402L<type_traits>
__cpp_lib_is_implicit_lifetime202302L<type_traits>
__cpp_lib_is_invocable201703L<type_traits>
__cpp_lib_is_layout_compatible201907L<type_traits>
__cpp_lib_is_nothrow_convertible201806L<type_traits>
__cpp_lib_is_null_pointer201309L<type_traits>
__cpp_lib_is_pointer_interconvertible201907L<type_traits>
__cpp_lib_is_scoped_enum202011L<type_traits>
__cpp_lib_is_sufficiently_aligned202411L<memory>
__cpp_lib_is_swappable201603L<type_traits>
__cpp_lib_is_virtual_base_of202406L<type_traits>
__cpp_lib_is_within_lifetime202306L<type_traits>
__cpp_lib_jthread201911L<stop_token> <thread>
__cpp_lib_latch201907L<latch>
__cpp_lib_launder201606L<new>
__cpp_lib_linalg202412L<linalg>
__cpp_lib_list_remove_return_type201806L<forward_list> <list>
__cpp_lib_logical_traits201510L<type_traits>
__cpp_lib_make_from_tuple201606L<tuple>
__cpp_lib_make_reverse_iterator201402L<iterator>
__cpp_lib_make_unique201304L<memory>
__cpp_lib_map_try_emplace201411L<map>
__cpp_lib_math_constants201907L<numbers>
__cpp_lib_math_special_functions201603L<cmath>
__cpp_lib_mdspan202406L<mdspan>
__cpp_lib_memory_resource201603L<memory_resource>
__cpp_lib_modules202207L
__cpp_lib_move_iterator_concept202207L<iterator>
__cpp_lib_move_only_function202110L<functional>
__cpp_lib_node_extract201606L<map> <set> <unordered_map> <unordered_set>
__cpp_lib_nonmember_container_access201411L<array> <deque> <forward_list> <iterator> <list> <map> <regex> <set> <string> <unordered_map> <unordered_set> <vector>
__cpp_lib_not_fn202306L<functional>
__cpp_lib_null_iterators201304L<iterator>
__cpp_lib_optional202110L<optional>
__cpp_lib_optional_range_support202406L<optional>
__cpp_lib_out_ptr202311L<memory>
__cpp_lib_parallel_algorithm201603L<algorithm> <numeric>
__cpp_lib_philox_engine202406L<random>
__cpp_lib_polymorphic_allocator201902L<memory_resource>
__cpp_lib_print202406L<print> <ostream>
__cpp_lib_quoted_string_io201304L<iomanip>
__cpp_lib_ranges202406L<algorithm> <functional> <iterator> <memory> <ranges>
__cpp_lib_ranges_as_const202311L<ranges>
__cpp_lib_ranges_as_rvalue202207L<ranges>
__cpp_lib_ranges_cache_latest202411L<ranges>
__cpp_lib_ranges_cartesian_product202207L<ranges>
__cpp_lib_ranges_chunk202202L<ranges>
__cpp_lib_ranges_chunk_by202202L<ranges>
__cpp_lib_ranges_concat202403L<ranges>
__cpp_lib_ranges_contains202207L<algorithm>
__cpp_lib_ranges_enumerate202302L<ranges>
__cpp_lib_ranges_find_last202207L<algorithm>
__cpp_lib_ranges_fold202207L<algorithm>
__cpp_lib_ranges_generate_random202403L<random>
__cpp_lib_ranges_iota202202L<numeric>
__cpp_lib_ranges_join_with202202L<ranges>
__cpp_lib_ranges_repeat202207L<ranges>
__cpp_lib_ranges_slide202202L<ranges>
__cpp_lib_ranges_starts_ends_with202106L<algorithm>
__cpp_lib_ranges_stride202207L<ranges>
__cpp_lib_ranges_to_container202202L<ranges>
__cpp_lib_ranges_zip202110L<ranges> <tuple> <utility>
__cpp_lib_ratio202306L<ratio>
__cpp_lib_raw_memory_algorithms202411L<memory>
__cpp_lib_rcu202306L<rcu>
__cpp_lib_reference_from_temporary202202L<type_traits>
__cpp_lib_reference_wrapper202403L<functional>
__cpp_lib_remove_cvref201711L<type_traits>
__cpp_lib_result_of_sfinae201210L<functional> <type_traits>
__cpp_lib_robust_nonmodifying_seq_ops201304L<algorithm>
__cpp_lib_sample201603L<algorithm>
__cpp_lib_saturation_arithmetic202311L<numeric>
__cpp_lib_scoped_lock201703L<mutex>
__cpp_lib_semaphore201907L<semaphore>
__cpp_lib_senders202406L<execution>
__cpp_lib_shared_mutex201505L<shared_mutex>
__cpp_lib_shared_ptr_arrays201707L<memory>
__cpp_lib_shared_ptr_weak_type201606L<memory>
__cpp_lib_shared_timed_mutex201402L<shared_mutex>
__cpp_lib_shift202202L<algorithm>
__cpp_lib_simd202411L<simd>
__cpp_lib_smart_ptr_for_overwrite202002L<memory>
__cpp_lib_smart_ptr_owner_equality202306L<memory>
__cpp_lib_source_location201907L<source_location>
__cpp_lib_span202311L<span>
__cpp_lib_span_initializer_list202311L<span>
__cpp_lib_spanstream202106L<spanstream>
__cpp_lib_ssize201902L<iterator>
__cpp_lib_sstream_from_string_view202306L<sstream>
__cpp_lib_stacktrace202011L<stacktrace>
__cpp_lib_start_lifetime_as202207L<memory>
__cpp_lib_starts_ends_with201711L<string> <string_view>
__cpp_lib_stdatomic_h202011L<stdatomic.h>
__cpp_lib_string_contains202011L<string> <string_view>
__cpp_lib_string_resize_and_overwrite202110L<string>
__cpp_lib_string_udls201304L<string>
__cpp_lib_string_view202403L<string> <string_view>
__cpp_lib_submdspan202411L<mdspan>
__cpp_lib_syncbuf201803L<syncstream>
__cpp_lib_text_encoding202306L<text_encoding>
__cpp_lib_three_way_comparison201907L<compare>
__cpp_lib_to_address201711L<memory>
__cpp_lib_to_array201907L<array>
__cpp_lib_to_chars202306L<charconv>
__cpp_lib_to_string202306L<string>
__cpp_lib_to_underlying202102L<utility>
__cpp_lib_transformation_trait_aliases201304L<type_traits>
__cpp_lib_transparent_operators201510L<memory> <functional>
__cpp_lib_tuple_element_t201402L<tuple>
__cpp_lib_tuple_like202311L<utility> <tuple> <map> <unordered_map>
__cpp_lib_tuples_by_type201304L<utility> <tuple>
__cpp_lib_type_identity201806L<type_traits>
__cpp_lib_type_trait_variable_templates201510L<type_traits>
__cpp_lib_uncaught_exceptions201411L<exception>
__cpp_lib_unordered_map_try_emplace201411L<unordered_map>
__cpp_lib_unreachable202202L<utility>
__cpp_lib_unwrap_ref201811L<type_traits>
__cpp_lib_variant202306L<variant>
__cpp_lib_void_t201411L<type_traits>
宏的总数量:245

注解

“值”列中的每个值都遵循以下模式:"yyyymmL",其中 "yyyy" 是年份,"mm" 是相应功能集被接受标准化的月份。如果给定特性的功能有所扩展,则某些值会在引入后有所增加。上表仅包含最新值(即来自最新的 C++ 语言标准草案)。包括初始值和中间值在内的所有值可在这里找到。

缺陷报告

下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。

缺陷报告应用于出版时的行为正确行为
LWG 4126C++20
C++23
某些完全独立的特性对应的特性测试宏不是独立的它们也是独立的

参阅

功能特性测试 (C++20)一套预处理器宏,用于测试与 C++ 语言和库功能相对应的功能
独立实现规定的标头C++ 文档
预定义宏表C++ 文档