Namespaces
Variants
Actions

Library feature-test macros (since C++20)

From cppreference.com
< cpp‎ | utility
 
 
 

Each of following macros is defined if the header <version> or one of the corresponding headers specified in the table is included.

Macro name Value Header Free-
standing
__cpp_lib_adaptor_iterator_pair_constructor202106L<stack><queue>
__cpp_lib_addressof_constexpr201603L<memory>Yes
__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>Yes
__cpp_lib_any201606L<any>
__cpp_lib_apply201603L<tuple>Yes
__cpp_lib_array_constexpr201811L<iterator><array>
__cpp_lib_as_const201510L<utility>Yes
__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>Yes
__cpp_lib_atomic_flag_test201907L<atomic>Yes
__cpp_lib_atomic_float201711L<atomic>Yes
__cpp_lib_atomic_is_always_lock_free201603L<atomic>Yes
__cpp_lib_atomic_lock_free_type_aliases201907L<atomic>
__cpp_lib_atomic_min_max202403L<atomic>Yes
__cpp_lib_atomic_ref202411L<atomic>Yes
__cpp_lib_atomic_shared_ptr201711L<memory>
__cpp_lib_atomic_value_initialization201911L<atomic><memory>Yes
__cpp_lib_atomic_wait201907L<atomic>Yes
__cpp_lib_barrier202302L<barrier>
__cpp_lib_bind_back202306L<functional>Yes
__cpp_lib_bind_front202306L<functional>Yes
__cpp_lib_bit_cast201806L<bit>Yes
__cpp_lib_bitops201907L<bit>Yes
__cpp_lib_bitset202306L<bitset>
__cpp_lib_bool_constant201505L<type_traits>Yes
__cpp_lib_bounded_array_traits201902L<type_traits>Yes
__cpp_lib_boyer_moore_searcher201603L<functional>
__cpp_lib_byte201603L<cstddef>Yes
__cpp_lib_byteswap202110L<bit>Yes
__cpp_lib_char8_t201907L<atomic><filesystem><istream><limits><locale><ostream><string><string_view>Yes
__cpp_lib_chrono202306L<chrono>
__cpp_lib_chrono_udls201304L<chrono>
__cpp_lib_clamp201603L<algorithm>
__cpp_lib_common_reference202302L<type_traits>Yes
__cpp_lib_common_reference_wrapper202302L<functional>Yes
__cpp_lib_complex_udls201309L<complex>
__cpp_lib_concepts202207L<concepts><compare>Yes
__cpp_lib_constexpr_algorithms202306L<algorithm><utility>
__cpp_lib_constexpr_atomic202411L<atomic>
__cpp_lib_constexpr_bitset202207L<bitset>
__cpp_lib_constexpr_charconv202207L<charconv>Yes
__cpp_lib_constexpr_cmath202306L<cmath><cstdlib>
__cpp_lib_constexpr_complex202306L<complex>
__cpp_lib_constexpr_deque202502L<deque>
__cpp_lib_constexpr_dynamic_alloc201907L<memory>
__cpp_lib_constexpr_exceptions202502L<exception><stdexcept><expected><optional><variant><format>
__cpp_lib_constexpr_flat_map202502L<flat_map>
__cpp_lib_constexpr_flat_set202502L<flat_set>
__cpp_lib_constexpr_forward_list202502L<forward_list>
__cpp_lib_constexpr_functional201907L<functional>Yes
__cpp_lib_constexpr_inplace_vector202502L<inplace_vector>
__cpp_lib_constexpr_iterator201811L<iterator>Yes
__cpp_lib_constexpr_list202502L<list>
__cpp_lib_constexpr_map202502L<map>
__cpp_lib_constexpr_memory202202L<memory>Yes
__cpp_lib_constexpr_new202406L<new>Yes
__cpp_lib_constexpr_numeric201911L<numeric>
__cpp_lib_constexpr_queue202502L<queue>
__cpp_lib_constexpr_set202502L<set>
__cpp_lib_constexpr_stack202502L<stack>
__cpp_lib_constexpr_string201907L<string>
__cpp_lib_constexpr_string_view201811L<string_view>
__cpp_lib_constexpr_tuple201811L<tuple>Yes
__cpp_lib_constexpr_typeinfo202106L<typeinfo>Yes
__cpp_lib_constexpr_unordered_map202502L<unordered_map>
__cpp_lib_constexpr_unordered_set202502L<unordered_set>
__cpp_lib_constexpr_utility201811L<utility>Yes
__cpp_lib_constexpr_vector201907L<vector>
__cpp_lib_constrained_equality202411L<utility><tuple><optional><variant><expected>Yes
__cpp_lib_containers_ranges202202L<vector><list><forward_list><map><set><unordered_map><unordered_set><deque><queue><stack><string>
__cpp_lib_contracts202502L<contracts>Yes
__cpp_lib_copyable_function202306L<functional>
__cpp_lib_coroutine201902L<coroutine>Yes
__cpp_lib_debugging202403L<debugging>Yes
__cpp_lib_destroying_delete201806L<new>Yes
__cpp_lib_enable_shared_from_this201603L<memory>
__cpp_lib_endian201907L<bit>Yes
__cpp_lib_erase_if202002L<string><deque><forward_list><list><vector><map><set><unordered_map><unordered_set>
__cpp_lib_exchange_function201304L<utility>Yes
__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>Yes
__cpp_lib_freestanding_algorithm202502L<algorithm>Yes
__cpp_lib_freestanding_array202311L<array>Yes
__cpp_lib_freestanding_char_traits202306L<string>Yes
__cpp_lib_freestanding_charconv202306L<charconv>Yes
__cpp_lib_freestanding_cstdlib202306L<cstdlib><cmath>Yes
__cpp_lib_freestanding_cstring202311L<cstring>Yes
__cpp_lib_freestanding_cwchar202306L<cwchar>Yes
__cpp_lib_freestanding_errc202306L<cerrno><system_error>Yes
__cpp_lib_freestanding_execution202502L<execution>Yes
__cpp_lib_freestanding_expected202311L<expected>Yes
__cpp_lib_freestanding_feature_test_macros202306LYes
__cpp_lib_freestanding_functional202306L<functional>Yes
__cpp_lib_freestanding_iterator202306L<iterator>Yes
__cpp_lib_freestanding_mdspan202311L<mdspan>Yes
__cpp_lib_freestanding_memory202502L<memory>Yes
__cpp_lib_freestanding_numeric202502L<numeric>Yes
__cpp_lib_freestanding_optional202311L<optional>Yes
__cpp_lib_freestanding_random202502L<random>Yes
__cpp_lib_freestanding_ranges202306L<ranges>Yes
__cpp_lib_freestanding_ratio202306L<ratio>Yes
__cpp_lib_freestanding_string_view202311L<string_view>Yes
__cpp_lib_freestanding_tuple202306L<tuple>Yes
__cpp_lib_freestanding_utility202306L<utility>Yes
__cpp_lib_freestanding_variant202311L<variant>Yes
__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>Yes
__cpp_lib_has_unique_object_representations201606L<type_traits>Yes
__cpp_lib_hazard_pointer202306L<hazard_pointer>
__cpp_lib_hive202502L<hive>
__cpp_lib_hypot201603L<cmath>
__cpp_lib_incomplete_container_elements201505L<forward_list><list><vector>
__cpp_lib_indirect202502L<memory>
__cpp_lib_inplace_vector202406L<inplace_vector>
__cpp_lib_int_pow2202002L<bit>Yes
__cpp_lib_integer_comparison_functions202002L<utility>
__cpp_lib_integer_sequence201304L<utility>Yes
__cpp_lib_integral_constant_callable201304L<type_traits>Yes
__cpp_lib_interpolate201902L<cmath><numeric>
__cpp_lib_invoke201411L<functional>Yes
__cpp_lib_invoke_r202106L<functional>Yes
__cpp_lib_ios_noreplace202207L<ios>
__cpp_lib_is_aggregate201703L<type_traits>Yes
__cpp_lib_is_constant_evaluated201811L<type_traits>Yes
__cpp_lib_is_final201402L<type_traits>Yes
__cpp_lib_is_implicit_lifetime202302L<type_traits>Yes
__cpp_lib_is_invocable201703L<type_traits>Yes
__cpp_lib_is_layout_compatible201907L<type_traits>Yes
__cpp_lib_is_nothrow_convertible201806L<type_traits>Yes
__cpp_lib_is_null_pointer201309L<type_traits>Yes
__cpp_lib_is_pointer_interconvertible201907L<type_traits>Yes
__cpp_lib_is_scoped_enum202011L<type_traits>Yes
__cpp_lib_is_sufficiently_aligned202411L<memory>
__cpp_lib_is_swappable201603L<type_traits>Yes
__cpp_lib_is_virtual_base_of202406L<type_traits>Yes
__cpp_lib_is_within_lifetime202306L<type_traits>Yes
__cpp_lib_jthread201911L<stop_token><thread>
__cpp_lib_latch201907L<latch>
__cpp_lib_launder201606L<new>Yes
__cpp_lib_linalg202412L<linalg>
__cpp_lib_list_remove_return_type201806L<forward_list><list>
__cpp_lib_logical_traits201510L<type_traits>Yes
__cpp_lib_make_from_tuple201606L<tuple>Yes
__cpp_lib_make_reverse_iterator201402L<iterator>Yes
__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>Yes
__cpp_lib_memory_resource201603L<memory_resource>
__cpp_lib_modules202207LYes
__cpp_lib_move_iterator_concept202207L<iterator>Yes
__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>Yes
__cpp_lib_not_fn202306L<functional>Yes
__cpp_lib_null_iterators201304L<iterator>Yes
__cpp_lib_optional202110L<optional>
__cpp_lib_optional_range_support202406L<optional>Yes
__cpp_lib_out_ptr202311L<memory>Yes
__cpp_lib_parallel_algorithm201603L<algorithm><numeric>
__cpp_lib_philox_engine202406L<random>
__cpp_lib_polymorphic202502L<memory>
__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>Yes
__cpp_lib_ranges_as_rvalue202207L<ranges>Yes
__cpp_lib_ranges_cache_latest202411L<ranges>Yes
__cpp_lib_ranges_cartesian_product202207L<ranges>Yes
__cpp_lib_ranges_chunk202202L<ranges>Yes
__cpp_lib_ranges_chunk_by202202L<ranges>Yes
__cpp_lib_ranges_concat202403L<ranges>Yes
__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>Yes
__cpp_lib_ranges_repeat202207L<ranges>Yes
__cpp_lib_ranges_reserve_hint202502L<ranges>
__cpp_lib_ranges_slide202202L<ranges>Yes
__cpp_lib_ranges_starts_ends_with202106L<algorithm>
__cpp_lib_ranges_stride202207L<ranges>Yes
__cpp_lib_ranges_to_container202202L<ranges>Yes
__cpp_lib_ranges_to_input202502L<ranges>Yes
__cpp_lib_ranges_zip202110L<ranges><tuple><utility>Yes
__cpp_lib_ratio202306L<ratio>Yes
__cpp_lib_raw_memory_algorithms202411L<memory>
__cpp_lib_rcu202306L<rcu>
__cpp_lib_reference_from_temporary202202L<type_traits>Yes
__cpp_lib_reference_wrapper202403L<functional>Yes
__cpp_lib_remove_cvref201711L<type_traits>Yes
__cpp_lib_result_of_sfinae201210L<functional><type_traits>Yes
__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_simd202502L<simd>
__cpp_lib_simd_complex202502L<simd>
__cpp_lib_smart_ptr_for_overwrite202002L<memory>
__cpp_lib_smart_ptr_owner_equality202306L<memory>
__cpp_lib_source_location201907L<source_location>Yes
__cpp_lib_span202311L<span>Yes
__cpp_lib_span_initializer_list202311L<span>Yes
__cpp_lib_spanstream202106L<spanstream>
__cpp_lib_ssize201902L<iterator>Yes
__cpp_lib_sstream_from_string_view202306L<sstream>
__cpp_lib_stacktrace202011L<stacktrace>
__cpp_lib_start_lifetime_as202207L<memory>Yes
__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>Yes
__cpp_lib_syncbuf201803L<syncstream>
__cpp_lib_text_encoding202306L<text_encoding>
__cpp_lib_three_way_comparison201907L<compare>Yes
__cpp_lib_to_address201711L<memory>Yes
__cpp_lib_to_array201907L<array>Yes
__cpp_lib_to_chars202306L<charconv>
__cpp_lib_to_string202306L<string>
__cpp_lib_to_underlying202102L<utility>Yes
__cpp_lib_transformation_trait_aliases201304L<type_traits>Yes
__cpp_lib_transparent_operators201510L<memory><functional>Yes
__cpp_lib_trivially_relocatable202502L<memory><type_traits>Yes
__cpp_lib_tuple_element_t201402L<tuple>Yes
__cpp_lib_tuple_like202311L<utility><tuple><map><unordered_map>
__cpp_lib_tuples_by_type201304L<utility><tuple>Yes
__cpp_lib_type_identity201806L<type_traits>Yes
__cpp_lib_type_trait_variable_templates201510L<type_traits>Yes
__cpp_lib_uncaught_exceptions201411L<exception>Yes
__cpp_lib_unordered_map_try_emplace201411L<unordered_map>
__cpp_lib_unreachable202202L<utility>Yes
__cpp_lib_unwrap_ref201811L<type_traits>Yes
__cpp_lib_variant202306L<variant>
__cpp_lib_void_t201411L<type_traits>Yes
Total number of macros: 267


A hardened implementation also defines the following macros:

Macro name Value Header Free-
standing
__cpp_lib_hardened_array202502L<array>
__cpp_lib_hardened_basic_string202502L<string>
__cpp_lib_hardened_basic_string_view202502L<string_view>
__cpp_lib_hardened_bitset202502L<bitset>
__cpp_lib_hardened_deque202502L<deque>
__cpp_lib_hardened_expected202502L<expected>
__cpp_lib_hardened_forward_list202502L<forward_list>
__cpp_lib_hardened_inplace_vector202502L<inplace_vector>
__cpp_lib_hardened_list202502L<list>
__cpp_lib_hardened_mdspan202502L<mdspan>
__cpp_lib_hardened_optional202502L<optional>
__cpp_lib_hardened_span202502L<span>
__cpp_lib_hardened_valarray202502L<valarray>
__cpp_lib_hardened_vector202502L<vector>
Total number of macros: 14

[edit]Notes

Each value in "Value" column follows the pattern: "yyyymmL", where "yyyy" is a year, and "mm" is a month when the corresponding feature-set was accepted for standardization. Some values where increased since the time of their introduction, if capabilities of given feature where extended. The table above contains only the most recent values (that is, taken from the latest C++ language draft standard). A full set of values, including the initial and intermediate ones, can be found in this table.

[edit]Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
LWG 4126C++20
C++23
some feature-test macros for fully
freestanding features were not freestanding
they are also
freestanding

[edit]See also

Feature testing(C++20) A set of preprocessor macros to test the corresponding to C++ language and library features
C++ documentation for Headers required for a freestanding implementation
C++ documentation for Predefined Macro Symbols
close