检测并打印C++编译器支持的feature(附Visual Studio 2022和gcc-12测试、对比结果)

C++标准快速迭代,不同的系统平台和编译器对C++各种新功能的支持不同,通过这个程序可以测试所用编译器对各个版本C++的支持情况。另一方面,可以在代码中通过这些宏针对不同版本编写不同的代码分支。
源码下面附上Visual Studio 2022的测试结果,基本上在2021年中就把C++23(当时还是草案)大部分功能都支持了。

1)测试代码

测试代码引用网址:https://en.cppreference.com/w/cpp/feature_test

#if __cplusplus < 201100
#  error "C++11 or better is required"
#endif

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <string>

#ifdef __has_include
# if __has_include(<version>)
#   include <version>
# endif
#endif

#define COMPILER_FEATURE_VALUE(value) #value
#define COMPILER_FEATURE_ENTRY(name) {
      
       #name, COMPILER_FEATURE_VALUE(name) },

#ifdef __has_cpp_attribute
# define COMPILER_ATTRIBUTE_VALUE_AS_STRING(s) #s
# define COMPILER_ATTRIBUTE_AS_NUMBER(x) COMPILER_ATTRIBUTE_VALUE_AS_STRING(x)
# define COMPILER_ATTRIBUTE_ENTRY(attr) \
  {
      
       #attr, COMPILER_ATTRIBUTE_AS_NUMBER(__has_cpp_attribute(attr)) },
#else
# define COMPILER_ATTRIBUTE_ENTRY(attr) {
      
       #attr, "_" },
#endif

// 更改这些选项以仅打印所需的信息。
static struct PrintOptions {
    
    
    constexpr static bool titles               = 1;
    constexpr static bool attributes           = 1;
    constexpr static bool general_features     = 1;
    constexpr static bool core_features        = 1;
    constexpr static bool lib_features         = 1;
    constexpr static bool supported_features   = 1;
    constexpr static bool unsupported_features = 1;
    constexpr static bool sorted_by_value      = 0;
    constexpr static bool cxx11                = 1;
    constexpr static bool cxx14                = 1;
    constexpr static bool cxx17                = 1;
    constexpr static bool cxx20                = 1;
    constexpr static bool cxx23                = 1;
}   print;

struct CompilerFeature {
    
    
    CompilerFeature(const char* name = nullptr, const char* value = nullptr)
            : name(name), value(value) {
    
    }
    const char* name; const char* value;
};

static CompilerFeature cxx[] = {
    
    
        COMPILER_FEATURE_ENTRY(__cplusplus)
        COMPILER_FEATURE_ENTRY(__cpp_exceptions)
        COMPILER_FEATURE_ENTRY(__cpp_rtti)
#if 0
        COMPILER_FEATURE_ENTRY(__GNUC__)
COMPILER_FEATURE_ENTRY(__GNUC_MINOR__)
COMPILER_FEATURE_ENTRY(__GNUC_PATCHLEVEL__)
COMPILER_FEATURE_ENTRY(__GNUG__)
COMPILER_FEATURE_ENTRY(__clang__)
COMPILER_FEATURE_ENTRY(__clang_major__)
COMPILER_FEATURE_ENTRY(__clang_minor__)
COMPILER_FEATURE_ENTRY(__clang_patchlevel__)
#endif
};
static CompilerFeature cxx11[] = {
    
    
        COMPILER_FEATURE_ENTRY(__cpp_alias_templates)
        COMPILER_FEATURE_ENTRY(__cpp_attributes)
        COMPILER_FEATURE_ENTRY(__cpp_constexpr)
        COMPILER_FEATURE_ENTRY(__cpp_decltype)
        COMPILER_FEATURE_ENTRY(__cpp_delegating_constructors)
        COMPILER_FEATURE_ENTRY(__cpp_inheriting_constructors)
        COMPILER_FEATURE_ENTRY(__cpp_initializer_lists)
        COMPILER_FEATURE_ENTRY(__cpp_lambdas)
        COMPILER_FEATURE_ENTRY(__cpp_nsdmi)
        COMPILER_FEATURE_ENTRY(__cpp_range_based_for)
        COMPILER_FEATURE_ENTRY(__cpp_raw_strings)
        COMPILER_FEATURE_ENTRY(__cpp_ref_qualifiers)
        COMPILER_FEATURE_ENTRY(__cpp_rvalue_references)
        COMPILER_FEATURE_ENTRY(__cpp_static_assert)
        COMPILER_FEATURE_ENTRY(__cpp_threadsafe_static_init)
        COMPILER_FEATURE_ENTRY(__cpp_unicode_characters)
        COMPILER_FEATURE_ENTRY(__cpp_unicode_literals)
        COMPILER_FEATURE_ENTRY(__cpp_user_defined_literals)
        COMPILER_FEATURE_ENTRY(__cpp_variadic_templates)
};
static CompilerFeature cxx14[] = {
    
    
        COMPILER_FEATURE_ENTRY(__cpp_aggregate_nsdmi)
        COMPILER_FEATURE_ENTRY(__cpp_binary_literals)
        COMPILER_FEATURE_ENTRY(__cpp_constexpr)
        COMPILER_FEATURE_ENTRY(__cpp_decltype_auto)
        COMPILER_FEATURE_ENTRY(__cpp_generic_lambdas)
        COMPILER_FEATURE_ENTRY(__cpp_init_captures)
        COMPILER_FEATURE_ENTRY(__cpp_return_type_deduction)
        COMPILER_FEATURE_ENTRY(__cpp_sized_deallocation)
        COMPILER_FEATURE_ENTRY(__cpp_variable_templates)
};
static CompilerFeature cxx14lib[] = {
    
    
        COMPILER_FEATURE_ENTRY(__cpp_lib_chrono_udls)
        COMPILER_FEATURE_ENTRY(__cpp_lib_complex_udls)
        COMPILER_FEATURE_ENTRY(__cpp_lib_exchange_function)
        COMPILER_FEATURE_ENTRY(__cpp_lib_generic_associative_lookup)
        COMPILER_FEATURE_ENTRY(__cpp_lib_integer_sequence)
        COMPILER_FEATURE_ENTRY(__cpp_lib_integral_constant_callable)
        COMPILER_FEATURE_ENTRY(__cpp_lib_is_final)
        COMPILER_FEATURE_ENTRY(__cpp_lib_is_null_pointer)
        COMPILER_FEATURE_ENTRY(__cpp_lib_make_reverse_iterator)
        COMPILER_FEATURE_ENTRY(__cpp_lib_make_unique)
        COMPILER_FEATURE_ENTRY(__cpp_lib_null_iterators)
        COMPILER_FEATURE_ENTRY(__cpp_lib_quoted_string_io)
        COMPILER_FEATURE_ENTRY(__cpp_lib_result_of_sfinae)
        COMPILER_FEATURE_ENTRY(__cpp_lib_robust_nonmodifying_seq_ops)
        COMPILER_FEATURE_ENTRY(__cpp_lib_shared_timed_mutex)
        COMPILER_FEATURE_ENTRY(__cpp_lib_string_udls)
        COMPILER_FEATURE_ENTRY(__cpp_lib_transformation_trait_aliases)
        COMPILER_FEATURE_ENTRY(__cpp_lib_transparent_operators)
        COMPILER_FEATURE_ENTRY(__cpp_lib_tuple_element_t)
        COMPILER_FEATURE_ENTRY(__cpp_lib_tuples_by_type)
};

static CompilerFeature cxx17[] = {
    
    
        COMPILER_FEATURE_ENTRY(__cpp_aggregate_bases)
        COMPILER_FEATURE_ENTRY(__cpp_aligned_new)
        COMPILER_FEATURE_ENTRY(__cpp_capture_star_this)
        COMPILER_FEATURE_ENTRY(__cpp_constexpr)
        COMPILER_FEATURE_ENTRY(__cpp_deduction_guides)
        COMPILER_FEATURE_ENTRY(__cpp_enumerator_attributes)
        COMPILER_FEATURE_ENTRY(__cpp_fold_expressions)
        COMPILER_FEATURE_ENTRY(__cpp_guaranteed_copy_elision)
        COMPILER_FEATURE_ENTRY(__cpp_hex_float)
        COMPILER_FEATURE_ENTRY(__cpp_if_constexpr)
        COMPILER_FEATURE_ENTRY(__cpp_inheriting_constructors)
        COMPILER_FEATURE_ENTRY(__cpp_inline_variables)
        COMPILER_FEATURE_ENTRY(__cpp_namespace_attributes)
        COMPILER_FEATURE_ENTRY(__cpp_noexcept_function_type)
        COMPILER_FEATURE_ENTRY(__cpp_nontype_template_args)
        COMPILER_FEATURE_ENTRY(__cpp_nontype_template_parameter_auto)
        COMPILER_FEATURE_ENTRY(__cpp_range_based_for)
        COMPILER_FEATURE_ENTRY(__cpp_static_assert)
        COMPILER_FEATURE_ENTRY(__cpp_structured_bindings)
        COMPILER_FEATURE_ENTRY(__cpp_template_template_args)
        COMPILER_FEATURE_ENTRY(__cpp_variadic_using)
};
static CompilerFeature cxx17lib[] = {
    
    
        COMPILER_FEATURE_ENTRY(__cpp_lib_addressof_constexpr)
        COMPILER_FEATURE_ENTRY(__cpp_lib_allocator_traits_is_always_equal)
        COMPILER_FEATURE_ENTRY(__cpp_lib_any)
        COMPILER_FEATURE_ENTRY(__cpp_lib_apply)
        COMPILER_FEATURE_ENTRY(__cpp_lib_array_constexpr)
        COMPILER_FEATURE_ENTRY(__cpp_lib_as_const)
        COMPILER_FEATURE_ENTRY(__cpp_lib_atomic_is_always_lock_free)
        COMPILER_FEATURE_ENTRY(__cpp_lib_bool_constant)
        COMPILER_FEATURE_ENTRY(__cpp_lib_boyer_moore_searcher)
        COMPILER_FEATURE_ENTRY(__cpp_lib_byte)
        COMPILER_FEATURE_ENTRY(__cpp_lib_chrono)
        COMPILER_FEATURE_ENTRY(__cpp_lib_clamp)
        COMPILER_FEATURE_ENTRY(__cpp_lib_enable_shared_from_this)
        COMPILER_FEATURE_ENTRY(__cpp_lib_execution)
        COMPILER_FEATURE_ENTRY(__cpp_lib_filesystem)
        COMPILER_FEATURE_ENTRY(__cpp_lib_gcd_lcm)
        COMPILER_FEATURE_ENTRY(__cpp_lib_hardware_interference_size)
        COMPILER_FEATURE_ENTRY(__cpp_lib_has_unique_object_representations)
        COMPILER_FEATURE_ENTRY(__cpp_lib_hypot)
        COMPILER_FEATURE_ENTRY(__cpp_lib_incomplete_container_elements)
        COMPILER_FEATURE_ENTRY(__cpp_lib_invoke)
        COMPILER_FEATURE_ENTRY(__cpp_lib_is_aggregate)
        COMPILER_FEATURE_ENTRY(__cpp_lib_is_invocable)
        COMPILER_FEATURE_ENTRY(__cpp_lib_is_swappable)
        COMPILER_FEATURE_ENTRY(__cpp_lib_launder)
        COMPILER_FEATURE_ENTRY(__cpp_lib_logical_traits)
        COMPILER_FEATURE_ENTRY(__cpp_lib_make_from_tuple)
        COMPILER_FEATURE_ENTRY(__cpp_lib_map_try_emplace)
        COMPILER_FEATURE_ENTRY(__cpp_lib_math_special_functions)
        COMPILER_FEATURE_ENTRY(__cpp_lib_memory_resource)
        COMPILER_FEATURE_ENTRY(__cpp_lib_node_extract)
        COMPILER_FEATURE_ENTRY(__cpp_lib_nonmember_container_access)
        COMPILER_FEATURE_ENTRY(__cpp_lib_not_fn)
        COMPILER_FEATURE_ENTRY(__cpp_lib_optional)
        COMPILER_FEATURE_ENTRY(__cpp_lib_parallel_algorithm)
        COMPILER_FEATURE_ENTRY(__cpp_lib_raw_memory_algorithms)
        COMPILER_FEATURE_ENTRY(__cpp_lib_sample)
        COMPILER_FEATURE_ENTRY(__cpp_lib_scoped_lock)
        COMPILER_FEATURE_ENTRY(__cpp_lib_shared_mutex)
        COMPILER_FEATURE_ENTRY(__cpp_lib_shared_ptr_arrays)
        COMPILER_FEATURE_ENTRY(__cpp_lib_shared_ptr_weak_type)
        COMPILER_FEATURE_ENTRY(__cpp_lib_string_view)
        COMPILER_FEATURE_ENTRY(__cpp_lib_to_chars)
        COMPILER_FEATURE_ENTRY(__cpp_lib_transparent_operators)
        COMPILER_FEATURE_ENTRY(__cpp_lib_type_trait_variable_templates)
        COMPILER_FEATURE_ENTRY(__cpp_lib_uncaught_exceptions)
        COMPILER_FEATURE_ENTRY(__cpp_lib_unordered_map_try_emplace)
        COMPILER_FEATURE_ENTRY(__cpp_lib_variant)
        COMPILER_FEATURE_ENTRY(__cpp_lib_void_t)
};

static CompilerFeature cxx20[] = {
    
    
        COMPILER_FEATURE_ENTRY(__cpp_aggregate_paren_init)
        COMPILER_FEATURE_ENTRY(__cpp_char8_t)
        COMPILER_FEATURE_ENTRY(__cpp_concepts)
        COMPILER_FEATURE_ENTRY(__cpp_conditional_explicit)
        COMPILER_FEATURE_ENTRY(__cpp_consteval)
        COMPILER_FEATURE_ENTRY(__cpp_constexpr)
        COMPILER_FEATURE_ENTRY(__cpp_constexpr_dynamic_alloc)
        COMPILER_FEATURE_ENTRY(__cpp_constexpr_in_decltype)
        COMPILER_FEATURE_ENTRY(__cpp_constinit)
        COMPILER_FEATURE_ENTRY(__cpp_deduction_guides)
        COMPILER_FEATURE_ENTRY(__cpp_designated_initializers)
        COMPILER_FEATURE_ENTRY(__cpp_generic_lambdas)
        COMPILER_FEATURE_ENTRY(__cpp_impl_coroutine)
        COMPILER_FEATURE_ENTRY(__cpp_impl_destroying_delete)
        COMPILER_FEATURE_ENTRY(__cpp_impl_three_way_comparison)
        COMPILER_FEATURE_ENTRY(__cpp_init_captures)
        COMPILER_FEATURE_ENTRY(__cpp_modules)
        COMPILER_FEATURE_ENTRY(__cpp_nontype_template_args)
        COMPILER_FEATURE_ENTRY(__cpp_using_enum)
};
static CompilerFeature cxx20lib[] = {
    
    
        COMPILER_FEATURE_ENTRY(__cpp_lib_array_constexpr)
        COMPILER_FEATURE_ENTRY(__cpp_lib_assume_aligned)
        COMPILER_FEATURE_ENTRY(__cpp_lib_atomic_flag_test)
        COMPILER_FEATURE_ENTRY(__cpp_lib_atomic_float)
        COMPILER_FEATURE_ENTRY(__cpp_lib_atomic_lock_free_type_aliases)
        COMPILER_FEATURE_ENTRY(__cpp_lib_atomic_ref)
        COMPILER_FEATURE_ENTRY(__cpp_lib_atomic_shared_ptr)
        COMPILER_FEATURE_ENTRY(__cpp_lib_atomic_value_initialization)
        COMPILER_FEATURE_ENTRY(__cpp_lib_atomic_wait)
        COMPILER_FEATURE_ENTRY(__cpp_lib_barrier)
        COMPILER_FEATURE_ENTRY(__cpp_lib_bind_front)
        COMPILER_FEATURE_ENTRY(__cpp_lib_bit_cast)
        COMPILER_FEATURE_ENTRY(__cpp_lib_bitops)
        COMPILER_FEATURE_ENTRY(__cpp_lib_bounded_array_traits)
        COMPILER_FEATURE_ENTRY(__cpp_lib_char8_t)
        COMPILER_FEATURE_ENTRY(__cpp_lib_chrono)
        COMPILER_FEATURE_ENTRY(__cpp_lib_concepts)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_algorithms)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_complex)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_dynamic_alloc)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_functional)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_iterator)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_memory)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_numeric)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_string)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_string_view)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_tuple)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_utility)
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_vector)
        COMPILER_FEATURE_ENTRY(__cpp_lib_coroutine)
        COMPILER_FEATURE_ENTRY(__cpp_lib_destroying_delete)
        COMPILER_FEATURE_ENTRY(__cpp_lib_endian)
        COMPILER_FEATURE_ENTRY(__cpp_lib_erase_if)
        COMPILER_FEATURE_ENTRY(__cpp_lib_execution)
        COMPILER_FEATURE_ENTRY(__cpp_lib_format)
        COMPILER_FEATURE_ENTRY(__cpp_lib_generic_unordered_lookup)
        COMPILER_FEATURE_ENTRY(__cpp_lib_int_pow2)
        COMPILER_FEATURE_ENTRY(__cpp_lib_integer_comparison_functions)
        COMPILER_FEATURE_ENTRY(__cpp_lib_interpolate)
        COMPILER_FEATURE_ENTRY(__cpp_lib_is_constant_evaluated)
        COMPILER_FEATURE_ENTRY(__cpp_lib_is_layout_compatible)
        COMPILER_FEATURE_ENTRY(__cpp_lib_is_nothrow_convertible)
        COMPILER_FEATURE_ENTRY(__cpp_lib_is_pointer_interconvertible)
        COMPILER_FEATURE_ENTRY(__cpp_lib_jthread)
        COMPILER_FEATURE_ENTRY(__cpp_lib_latch)
        COMPILER_FEATURE_ENTRY(__cpp_lib_list_remove_return_type)
        COMPILER_FEATURE_ENTRY(__cpp_lib_math_constants)
        COMPILER_FEATURE_ENTRY(__cpp_lib_polymorphic_allocator)
        COMPILER_FEATURE_ENTRY(__cpp_lib_ranges)
        COMPILER_FEATURE_ENTRY(__cpp_lib_remove_cvref)
        COMPILER_FEATURE_ENTRY(__cpp_lib_semaphore)
        COMPILER_FEATURE_ENTRY(__cpp_lib_shared_ptr_arrays)
        COMPILER_FEATURE_ENTRY(__cpp_lib_shift)
        COMPILER_FEATURE_ENTRY(__cpp_lib_smart_ptr_for_overwrite)
        COMPILER_FEATURE_ENTRY(__cpp_lib_source_location)
        COMPILER_FEATURE_ENTRY(__cpp_lib_span)
        COMPILER_FEATURE_ENTRY(__cpp_lib_ssize)
        COMPILER_FEATURE_ENTRY(__cpp_lib_starts_ends_with)
        COMPILER_FEATURE_ENTRY(__cpp_lib_string_view)
        COMPILER_FEATURE_ENTRY(__cpp_lib_syncbuf)
        COMPILER_FEATURE_ENTRY(__cpp_lib_three_way_comparison)
        COMPILER_FEATURE_ENTRY(__cpp_lib_to_address)
        COMPILER_FEATURE_ENTRY(__cpp_lib_to_array)
        COMPILER_FEATURE_ENTRY(__cpp_lib_type_identity)
        COMPILER_FEATURE_ENTRY(__cpp_lib_unwrap_ref)
};

static CompilerFeature cxx23[] = {
    
    
//< 继续填充
        COMPILER_FEATURE_ENTRY(__cpp_if_consteval)
        COMPILER_FEATURE_ENTRY(__cpp_size_t_suffix)
};
static CompilerFeature cxx23lib[] = {
    
    
//< 继续填充
        COMPILER_FEATURE_ENTRY(__cpp_lib_constexpr_typeinfo)
        COMPILER_FEATURE_ENTRY(__cpp_lib_invoke_r)
        COMPILER_FEATURE_ENTRY(__cpp_lib_is_scoped_enum)
        COMPILER_FEATURE_ENTRY(__cpp_lib_stacktrace)
        COMPILER_FEATURE_ENTRY(__cpp_lib_stdatomic_h)
        COMPILER_FEATURE_ENTRY(__cpp_lib_string_contains)
        COMPILER_FEATURE_ENTRY(__cpp_lib_to_underlying)
        COMPILER_FEATURE_ENTRY(__cpp_lib_variant)
};

static CompilerFeature attributes[] = {
    
    
        COMPILER_ATTRIBUTE_ENTRY(carries_dependency)
        COMPILER_ATTRIBUTE_ENTRY(deprecated)
        COMPILER_ATTRIBUTE_ENTRY(fallthrough)
        COMPILER_ATTRIBUTE_ENTRY(likely)
        COMPILER_ATTRIBUTE_ENTRY(maybe_unused)
        COMPILER_ATTRIBUTE_ENTRY(nodiscard)
        COMPILER_ATTRIBUTE_ENTRY(noreturn)
        COMPILER_ATTRIBUTE_ENTRY(no_unique_address)
        COMPILER_ATTRIBUTE_ENTRY(unlikely)
};

constexpr bool is_feature_supported(const CompilerFeature& x) {
    
    
    return x.value[0] != '_' && x.value[0] != '0' ;
}

inline void print_compiler_feature(const CompilerFeature& x) {
    
    
    constexpr static int max_name_length = 44; //< Update if necessary
    std::string value{
    
     is_feature_supported(x) ? x.value : "------" };
    if (value.back() == 'L') value.pop_back(); //~ 201603L -> 201603
    // value.insert(4, 1, '-'); //~ 201603 -> 2016-03
    if ( (print.supported_features && is_feature_supported(x))
         or (print.unsupported_features && !is_feature_supported(x))) {
    
    
        std::cout << std::left << std::setw(max_name_length)
                  << x.name << " " << value << '\n';
    }
}

template<std::size_t N>
inline void show(char const* title, CompilerFeature (&features)[N]) {
    
    
    if (print.titles) {
    
    
        std::cout << '\n' << std::left << title << '\n';
    }
    if (print.sorted_by_value) {
    
    
        std::sort(std::begin(features), std::end(features),
                  [](CompilerFeature const& lhs, CompilerFeature const& rhs) {
    
    
                      return std::strcmp(lhs.value, rhs.value) < 0;
                  });
    }
    for (const CompilerFeature& x : features) {
    
    
        print_compiler_feature(x);
    }
}

int main() {
    
    
    if (print.general_features) show("C++ GENERAL", cxx);
    if (print.cxx11 && print.core_features) show("C++11 CORE", cxx11);
    if (print.cxx14 && print.core_features) show("C++14 CORE", cxx14);
    if (print.cxx14 && print.lib_features ) show("C++14 LIB" , cxx14lib);
    if (print.cxx17 && print.core_features) show("C++17 CORE", cxx17);
    if (print.cxx17 && print.lib_features ) show("C++17 LIB" , cxx17lib);
    if (print.cxx20 && print.core_features) show("C++20 CORE", cxx20);
    if (print.cxx20 && print.lib_features ) show("C++20 LIB" , cxx20lib);
    if (print.cxx23 && print.core_features) show("C++23 CORE", cxx23);
    if (print.cxx23 && print.lib_features ) show("C++23 LIB" , cxx23lib);
    if (print.attributes) show("ATTRIBUTES", attributes);
}

2)测试结果: Visual Studio 2022

以下是Visual Studio 2022的测试结果,支持的feature比较全。

  1. 需要在项目属性中选择最新的C++版本。需要选择“预览”选项,C++23的feature才会支持。
    在这里插入图片描述

  2. vs编译器中__cplusplus对应值是199711,测试程序开头(前3行)的监测不能通过,可以注释掉或者修改第一行的数值。
    gcc或者clang都没可以直接测试通过。

  3. 测试结果中显示对标准中attributes支持不好,在代码中实际测试大部分attributes都是支持的。
    可能是对测试宏的检测方式不兼容,这个问题抽空调查一下(todo)。

C++ GENERAL
__cplusplus                                  199711
__cpp_exceptions                             199711
__cpp_rtti                                   199711

C++11 CORE
__cpp_alias_templates                        200704
__cpp_attributes                             200809
__cpp_constexpr                              202002
__cpp_decltype                               200707
__cpp_delegating_constructors                200604
__cpp_inheriting_constructors                201511
__cpp_initializer_lists                      200806
__cpp_lambdas                                200907
__cpp_nsdmi                                  200809
__cpp_range_based_for                        201603
__cpp_raw_strings                            200710
__cpp_ref_qualifiers                         200710
__cpp_rvalue_references                      200610
__cpp_static_assert                          201411
__cpp_threadsafe_static_init                 200806
__cpp_unicode_characters                     200704
__cpp_unicode_literals                       200710
__cpp_user_defined_literals                  200809
__cpp_variadic_templates                     200704

C++14 CORE
__cpp_aggregate_nsdmi                        201304
__cpp_binary_literals                        201304
__cpp_constexpr                              202002
__cpp_decltype_auto                          201304
__cpp_generic_lambdas                        201707
__cpp_init_captures                          201803
__cpp_return_type_deduction                  201304
__cpp_sized_deallocation                     201309
__cpp_variable_templates                     201304

C++14 LIB
__cpp_lib_chrono_udls                        201304
__cpp_lib_complex_udls                       201309
__cpp_lib_exchange_function                  201304
__cpp_lib_generic_associative_lookup         201304
__cpp_lib_integer_sequence                   201304
__cpp_lib_integral_constant_callable         201304
__cpp_lib_is_final                           201402
__cpp_lib_is_null_pointer                    201309
__cpp_lib_make_reverse_iterator              201402
__cpp_lib_make_unique                        201304
__cpp_lib_null_iterators                     201304
__cpp_lib_quoted_string_io                   201304
__cpp_lib_result_of_sfinae                   201210
__cpp_lib_robust_nonmodifying_seq_ops        201304
__cpp_lib_shared_timed_mutex                 201402
__cpp_lib_string_udls                        201304
__cpp_lib_transformation_trait_aliases       201304
__cpp_lib_transparent_operators              201510
__cpp_lib_tuple_element_t                    201402
__cpp_lib_tuples_by_type                     201304

C++17 CORE
__cpp_aggregate_bases                        201603
__cpp_aligned_new                            201606
__cpp_capture_star_this                      201603
__cpp_constexpr                              202002
__cpp_deduction_guides                       201907
__cpp_enumerator_attributes                  201411
__cpp_fold_expressions                       201603
__cpp_guaranteed_copy_elision                201606
__cpp_hex_float                              201603
__cpp_if_constexpr                           201606
__cpp_inheriting_constructors                201511
__cpp_inline_variables                       201606
__cpp_namespace_attributes                   201411
__cpp_noexcept_function_type                 201510
__cpp_nontype_template_args                  201911
__cpp_nontype_template_parameter_auto        201606
__cpp_range_based_for                        201603
__cpp_static_assert                          201411
__cpp_structured_bindings                    201606
__cpp_template_template_args                 201611
__cpp_variadic_using                         201611

C++17 LIB
__cpp_lib_addressof_constexpr                201603
__cpp_lib_allocator_traits_is_always_equal   201411
__cpp_lib_any                                201606
__cpp_lib_apply                              201603
__cpp_lib_array_constexpr                    201811
__cpp_lib_as_const                           201510
__cpp_lib_atomic_is_always_lock_free         201603
__cpp_lib_bool_constant                      201505
__cpp_lib_boyer_moore_searcher               201603
__cpp_lib_byte                               201603
__cpp_lib_chrono                             201907
__cpp_lib_clamp                              201603
__cpp_lib_enable_shared_from_this            201603
__cpp_lib_execution                          201902
__cpp_lib_filesystem                         201703
__cpp_lib_gcd_lcm                            201606
__cpp_lib_hardware_interference_size         201703
__cpp_lib_has_unique_object_representations  201606
__cpp_lib_hypot                              201603
__cpp_lib_incomplete_container_elements      201505
__cpp_lib_invoke                             201411
__cpp_lib_is_aggregate                       201703
__cpp_lib_is_invocable                       201703
__cpp_lib_is_swappable                       201603
__cpp_lib_launder                            201606
__cpp_lib_logical_traits                     201510
__cpp_lib_make_from_tuple                    201606
__cpp_lib_map_try_emplace                    201411
__cpp_lib_math_special_functions             201603
__cpp_lib_memory_resource                    201603
__cpp_lib_node_extract                       201606
__cpp_lib_nonmember_container_access         201411
__cpp_lib_not_fn                             201603
__cpp_lib_optional                           202110
__cpp_lib_parallel_algorithm                 201603
__cpp_lib_raw_memory_algorithms              201606
__cpp_lib_sample                             201603
__cpp_lib_scoped_lock                        201703
__cpp_lib_shared_mutex                       201505
__cpp_lib_shared_ptr_arrays                  201707
__cpp_lib_shared_ptr_weak_type               201606
__cpp_lib_string_view                        201803
__cpp_lib_to_chars                           201611
__cpp_lib_transparent_operators              201510
__cpp_lib_type_trait_variable_templates      201510
__cpp_lib_uncaught_exceptions                201411
__cpp_lib_unordered_map_try_emplace          201411
__cpp_lib_variant                            202106
__cpp_lib_void_t                             201411

C++20 CORE
__cpp_aggregate_paren_init                   201902
__cpp_char8_t                                202207
__cpp_concepts                               202002
__cpp_conditional_explicit                   201806
__cpp_consteval                              201811
__cpp_constexpr                              202002
__cpp_constexpr_dynamic_alloc                201907
__cpp_constexpr_in_decltype                  ------
__cpp_constinit                              201907
__cpp_deduction_guides                       201907
__cpp_designated_initializers                201707
__cpp_generic_lambdas                        201707
__cpp_impl_coroutine                         201902
__cpp_impl_destroying_delete                 201806
__cpp_impl_three_way_comparison              201907
__cpp_init_captures                          201803
__cpp_modules                                201907
__cpp_nontype_template_args                  201911
__cpp_using_enum                             201907

C++20 LIB
__cpp_lib_array_constexpr                    201811
__cpp_lib_assume_aligned                     201811
__cpp_lib_atomic_flag_test                   201907
__cpp_lib_atomic_float                       201711
__cpp_lib_atomic_lock_free_type_aliases      201907
__cpp_lib_atomic_ref                         201806
__cpp_lib_atomic_shared_ptr                  201711
__cpp_lib_atomic_value_initialization        201911
__cpp_lib_atomic_wait                        201907
__cpp_lib_barrier                            201907
__cpp_lib_bind_front                         201907
__cpp_lib_bit_cast                           201806
__cpp_lib_bitops                             201907
__cpp_lib_bounded_array_traits               201902
__cpp_lib_char8_t                            201907
__cpp_lib_chrono                             201907
__cpp_lib_concepts                           202002
__cpp_lib_constexpr_algorithms               201806
__cpp_lib_constexpr_complex                  201711
__cpp_lib_constexpr_dynamic_alloc            201907
__cpp_lib_constexpr_functional               201907
__cpp_lib_constexpr_iterator                 201811
__cpp_lib_constexpr_memory                   202202
__cpp_lib_constexpr_numeric                  201911
__cpp_lib_constexpr_string                   201907
__cpp_lib_constexpr_string_view              201811
__cpp_lib_constexpr_tuple                    201811
__cpp_lib_constexpr_utility                  201811
__cpp_lib_constexpr_vector                   201907
__cpp_lib_coroutine                          201902
__cpp_lib_destroying_delete                  201806
__cpp_lib_endian                             201907
__cpp_lib_erase_if                           202002
__cpp_lib_execution                          201902
__cpp_lib_format                             202207
__cpp_lib_generic_unordered_lookup           201811
__cpp_lib_int_pow2                           202002
__cpp_lib_integer_comparison_functions       202002
__cpp_lib_interpolate                        201902
__cpp_lib_is_constant_evaluated              201811
__cpp_lib_is_layout_compatible               201907
__cpp_lib_is_nothrow_convertible             201806
__cpp_lib_is_pointer_interconvertible        201907
__cpp_lib_jthread                            201911
__cpp_lib_latch                              201907
__cpp_lib_list_remove_return_type            201806
__cpp_lib_math_constants                     201907
__cpp_lib_polymorphic_allocator              201902
__cpp_lib_ranges                             202207
__cpp_lib_remove_cvref                       201711
__cpp_lib_semaphore                          201907
__cpp_lib_shared_ptr_arrays                  201707
__cpp_lib_shift                              202202
__cpp_lib_smart_ptr_for_overwrite            202002
__cpp_lib_source_location                    201907
__cpp_lib_span                               202002
__cpp_lib_ssize                              201902
__cpp_lib_starts_ends_with                   201711
__cpp_lib_string_view                        201803
__cpp_lib_syncbuf                            201803
__cpp_lib_three_way_comparison               201907
__cpp_lib_to_address                         201711
__cpp_lib_to_array                           201907
__cpp_lib_type_identity                      201806
__cpp_lib_unwrap_ref                         201811

C++23 CORE
__cpp_if_consteval                           ------
__cpp_size_t_suffix                          ------

C++23 LIB
__cpp_lib_constexpr_typeinfo                 202106
__cpp_lib_invoke_r                           202106
__cpp_lib_is_scoped_enum                     202011
__cpp_lib_stacktrace                         202011
__cpp_lib_stdatomic_h                        202011
__cpp_lib_string_contains                    202011
__cpp_lib_to_underlying                      202102
__cpp_lib_variant                            202106

ATTRIBUTES
carries_dependency                           ------
deprecated                                   ------
fallthrough                                  ------
likely                                       ------
maybe_unused                                 ------
nodiscard                                    ------
noreturn                                     ------
no_unique_address                            ------
unlikely                                     ------

3)测试结果:g++ -12 (on Ubuntu 22.04)

以下是gcc的测试结果。从结果看对C++的支持也比较全面,和vs2022对比有少量差异。最后附上一个二者的对比。

  1. 编译时需要通过参数(–std)指定C++版本:
$ g++-12 -std=c++23 main.cpp -o main
  1. Ubuntu 22.04上默认是g++ -11,升级成g++ -12后进行测试(有少量更新)。
C++ GENERAL
__cplusplus                                  202100
__cpp_exceptions                             199711
__cpp_rtti                                   199711

C++11 CORE
__cpp_alias_templates                        200704
__cpp_attributes                             200809
__cpp_constexpr                              202110
__cpp_decltype                               200707
__cpp_delegating_constructors                200604
__cpp_inheriting_constructors                201511
__cpp_initializer_lists                      200806
__cpp_lambdas                                200907
__cpp_nsdmi                                  200809
__cpp_range_based_for                        201603
__cpp_raw_strings                            200710
__cpp_ref_qualifiers                         200710
__cpp_rvalue_references                      200610
__cpp_static_assert                          201411
__cpp_threadsafe_static_init                 200806
__cpp_unicode_characters                     201411
__cpp_unicode_literals                       200710
__cpp_user_defined_literals                  200809
__cpp_variadic_templates                     200704

C++14 CORE
__cpp_aggregate_nsdmi                        201304
__cpp_binary_literals                        201304
__cpp_constexpr                              202110
__cpp_decltype_auto                          201304
__cpp_generic_lambdas                        201707
__cpp_init_captures                          201803
__cpp_return_type_deduction                  201304
__cpp_sized_deallocation                     201309
__cpp_variable_templates                     201304

C++14 LIB
__cpp_lib_chrono_udls                        201304
__cpp_lib_complex_udls                       201309
__cpp_lib_exchange_function                  201304
__cpp_lib_generic_associative_lookup         201304
__cpp_lib_integer_sequence                   201304
__cpp_lib_integral_constant_callable         201304
__cpp_lib_is_final                           201402
__cpp_lib_is_null_pointer                    201309
__cpp_lib_make_reverse_iterator              201402
__cpp_lib_make_unique                        201304
__cpp_lib_null_iterators                     201304
__cpp_lib_quoted_string_io                   201304
__cpp_lib_result_of_sfinae                   201210
__cpp_lib_robust_nonmodifying_seq_ops        201304
__cpp_lib_shared_timed_mutex                 201402
__cpp_lib_string_udls                        201304
__cpp_lib_transformation_trait_aliases       201304
__cpp_lib_transparent_operators              201510
__cpp_lib_tuple_element_t                    201402
__cpp_lib_tuples_by_type                     201304

C++17 CORE
__cpp_aggregate_bases                        201603
__cpp_aligned_new                            201606
__cpp_capture_star_this                      201603
__cpp_constexpr                              202110
__cpp_deduction_guides                       201907
__cpp_enumerator_attributes                  201411
__cpp_fold_expressions                       201603
__cpp_guaranteed_copy_elision                201606
__cpp_hex_float                              201603
__cpp_if_constexpr                           201606
__cpp_inheriting_constructors                201511
__cpp_inline_variables                       201606
__cpp_namespace_attributes                   201411
__cpp_noexcept_function_type                 201510
__cpp_nontype_template_args                  201911
__cpp_nontype_template_parameter_auto        201606
__cpp_range_based_for                        201603
__cpp_static_assert                          201411
__cpp_structured_bindings                    201606
__cpp_template_template_args                 201611
__cpp_variadic_using                         201611

C++17 LIB
__cpp_lib_addressof_constexpr                201603
__cpp_lib_allocator_traits_is_always_equal   201411
__cpp_lib_any                                201606
__cpp_lib_apply                              201603
__cpp_lib_array_constexpr                    201811
__cpp_lib_as_const                           201510
__cpp_lib_atomic_is_always_lock_free         201603
__cpp_lib_bool_constant                      201505
__cpp_lib_boyer_moore_searcher               201603
__cpp_lib_byte                               201603
__cpp_lib_chrono                             201611
__cpp_lib_clamp                              201603
__cpp_lib_enable_shared_from_this            201603
__cpp_lib_execution                          201902
__cpp_lib_filesystem                         201703
__cpp_lib_gcd_lcm                            201606
__cpp_lib_hardware_interference_size         201703
__cpp_lib_has_unique_object_representations  201606
__cpp_lib_hypot                              201603
__cpp_lib_incomplete_container_elements      201505
__cpp_lib_invoke                             201411
__cpp_lib_is_aggregate                       201703
__cpp_lib_is_invocable                       201703
__cpp_lib_is_swappable                       201603
__cpp_lib_launder                            201606
__cpp_lib_logical_traits                     201510
__cpp_lib_make_from_tuple                    201606
__cpp_lib_map_try_emplace                    201411
__cpp_lib_math_special_functions             201603
__cpp_lib_memory_resource                    201603
__cpp_lib_node_extract                       201606
__cpp_lib_nonmember_container_access         201411
__cpp_lib_not_fn                             201603
__cpp_lib_optional                           202110
__cpp_lib_parallel_algorithm                 201603
__cpp_lib_raw_memory_algorithms              201606
__cpp_lib_sample                             201603
__cpp_lib_scoped_lock                        201703
__cpp_lib_shared_mutex                       201505
__cpp_lib_shared_ptr_arrays                  201707
__cpp_lib_shared_ptr_weak_type               201606
__cpp_lib_string_view                        201803
__cpp_lib_to_chars                           201611
__cpp_lib_transparent_operators              201510
__cpp_lib_type_trait_variable_templates      201510
__cpp_lib_uncaught_exceptions                201411
__cpp_lib_unordered_map_try_emplace          201411
__cpp_lib_variant                            202106
__cpp_lib_void_t                             201411

C++20 CORE
__cpp_aggregate_paren_init                   201902
__cpp_char8_t                                201811
__cpp_concepts                               202002
__cpp_conditional_explicit                   201806
__cpp_consteval                              201811
__cpp_constexpr                              202110
__cpp_constexpr_dynamic_alloc                201907
__cpp_constexpr_in_decltype                  201711
__cpp_constinit                              201907
__cpp_deduction_guides                       201907
__cpp_designated_initializers                201707
__cpp_generic_lambdas                        201707
__cpp_impl_coroutine                         201902
__cpp_impl_destroying_delete                 201806
__cpp_impl_three_way_comparison              201907
__cpp_init_captures                          201803
__cpp_modules                                ------
__cpp_nontype_template_args                  201911
__cpp_using_enum                             201907

C++20 LIB
__cpp_lib_array_constexpr                    201811
__cpp_lib_assume_aligned                     201811
__cpp_lib_atomic_flag_test                   201907
__cpp_lib_atomic_float                       201711
__cpp_lib_atomic_lock_free_type_aliases      ------
__cpp_lib_atomic_ref                         201806
__cpp_lib_atomic_shared_ptr                  201711
__cpp_lib_atomic_value_initialization        201911
__cpp_lib_atomic_wait                        201907
__cpp_lib_barrier                            201907
__cpp_lib_bind_front                         201907
__cpp_lib_bit_cast                           201806
__cpp_lib_bitops                             201907
__cpp_lib_bounded_array_traits               201902
__cpp_lib_char8_t                            201907
__cpp_lib_chrono                             201611
__cpp_lib_concepts                           202002
__cpp_lib_constexpr_algorithms               201806
__cpp_lib_constexpr_complex                  201711
__cpp_lib_constexpr_dynamic_alloc            201907
__cpp_lib_constexpr_functional               201907
__cpp_lib_constexpr_iterator                 201811
__cpp_lib_constexpr_memory                   202202
__cpp_lib_constexpr_numeric                  201911
__cpp_lib_constexpr_string                   201907
__cpp_lib_constexpr_string_view              201811
__cpp_lib_constexpr_tuple                    201811
__cpp_lib_constexpr_utility                  201811
__cpp_lib_constexpr_vector                   201907
__cpp_lib_coroutine                          201902
__cpp_lib_destroying_delete                  201806
__cpp_lib_endian                             201907
__cpp_lib_erase_if                           202002
__cpp_lib_execution                          201902
__cpp_lib_format                             ------
__cpp_lib_generic_unordered_lookup           201811
__cpp_lib_int_pow2                           202002
__cpp_lib_integer_comparison_functions       202002
__cpp_lib_interpolate                        201902
__cpp_lib_is_constant_evaluated              201811
__cpp_lib_is_layout_compatible               201907
__cpp_lib_is_nothrow_convertible             201806
__cpp_lib_is_pointer_interconvertible        201907
__cpp_lib_jthread                            201911
__cpp_lib_latch                              201907
__cpp_lib_list_remove_return_type            201806
__cpp_lib_math_constants                     201907
__cpp_lib_polymorphic_allocator              201902
__cpp_lib_ranges                             202110
__cpp_lib_remove_cvref                       201711
__cpp_lib_semaphore                          201907
__cpp_lib_shared_ptr_arrays                  201707
__cpp_lib_shift                              201806
__cpp_lib_smart_ptr_for_overwrite            202002
__cpp_lib_source_location                    201907
__cpp_lib_span                               202002
__cpp_lib_ssize                              201902
__cpp_lib_starts_ends_with                   201711
__cpp_lib_string_view                        201803
__cpp_lib_syncbuf                            201803
__cpp_lib_three_way_comparison               201907
__cpp_lib_to_address                         201711
__cpp_lib_to_array                           201907
__cpp_lib_type_identity                      201806
__cpp_lib_unwrap_ref                         201811

C++23 CORE
__cpp_if_consteval                           202106
__cpp_size_t_suffix                          202011

C++23 LIB
__cpp_lib_constexpr_typeinfo                 202106
__cpp_lib_invoke_r                           202106
__cpp_lib_is_scoped_enum                     202011
__cpp_lib_stacktrace                         ------
__cpp_lib_stdatomic_h                        202011
__cpp_lib_string_contains                    202011
__cpp_lib_to_underlying                      202102
__cpp_lib_variant                            202106

ATTRIBUTES
carries_dependency                           ------
deprecated                                   201309
fallthrough                                  201603
likely                                       201803
maybe_unused                                 201603
nodiscard                                    201907
noreturn                                     200809
no_unique_address                            201803
unlikely                                     201803

4)对比:Visual Studio 2022 vs. g++ -12

在这里插入图片描述

5)Android / AOSP 11测试结果

说明:需要在blueprint文件中添加参数:cpp_std: “experimental”
从实测结果看,已基本支持C++20的核心功能,

C++ GENERAL
__cplusplus                                  201707
__cpp_exceptions                             ------
__cpp_rtti                                   ------

C++11 CORE
__cpp_alias_templates                        200704
__cpp_attributes                             200809
__cpp_constexpr                              201907
__cpp_decltype                               200707
__cpp_delegating_constructors                200604
__cpp_inheriting_constructors                201511
__cpp_initializer_lists                      200806
__cpp_lambdas                                200907
__cpp_nsdmi                                  200809
__cpp_range_based_for                        201603
__cpp_raw_strings                            200710
__cpp_ref_qualifiers                         200710
__cpp_rvalue_references                      200610
__cpp_static_assert                          201411
__cpp_threadsafe_static_init                 200806
__cpp_unicode_characters                     200704
__cpp_unicode_literals                       200710
__cpp_user_defined_literals                  200809
__cpp_variadic_templates                     200704

C++14 CORE
__cpp_aggregate_nsdmi                        201304
__cpp_binary_literals                        201304
__cpp_constexpr                              201907
__cpp_decltype_auto                          201304
__cpp_generic_lambdas                        201707
__cpp_init_captures                          201803
__cpp_return_type_deduction                  201304
__cpp_sized_deallocation                     ------
__cpp_variable_templates                     201304

C++14 LIB
__cpp_lib_chrono_udls                        ------
__cpp_lib_complex_udls                       ------
__cpp_lib_exchange_function                  ------
__cpp_lib_generic_associative_lookup         ------
__cpp_lib_integer_sequence                   ------
__cpp_lib_integral_constant_callable         ------
__cpp_lib_is_final                           ------
__cpp_lib_is_null_pointer                    ------
__cpp_lib_make_reverse_iterator              ------
__cpp_lib_make_unique                        ------
__cpp_lib_null_iterators                     ------
__cpp_lib_quoted_string_io                   ------
__cpp_lib_result_of_sfinae                   ------
__cpp_lib_robust_nonmodifying_seq_ops        ------
__cpp_lib_shared_timed_mutex                 ------
__cpp_lib_string_udls                        ------
__cpp_lib_transformation_trait_aliases       ------
__cpp_lib_transparent_operators              ------
__cpp_lib_tuple_element_t                    ------
__cpp_lib_tuples_by_type                     ------

C++17 CORE
__cpp_aggregate_bases                        201603
__cpp_aligned_new                            201606
__cpp_capture_star_this                      201603
__cpp_constexpr                              201907
__cpp_deduction_guides                       201703
__cpp_enumerator_attributes                  201411
__cpp_fold_expressions                       201603
__cpp_guaranteed_copy_elision                201606
__cpp_hex_float                              201603
__cpp_if_constexpr                           201606
__cpp_inheriting_constructors                201511
__cpp_inline_variables                       201606
__cpp_namespace_attributes                   201411
__cpp_noexcept_function_type                 201510
__cpp_nontype_template_args                  201411
__cpp_nontype_template_parameter_auto        201606
__cpp_range_based_for                        201603
__cpp_static_assert                          201411
__cpp_structured_bindings                    201606
__cpp_template_template_args                 ------
__cpp_variadic_using                         201611

C++17 LIB
__cpp_lib_addressof_constexpr                ------
__cpp_lib_allocator_traits_is_always_equal   ------
__cpp_lib_any                                ------
__cpp_lib_apply                              ------
__cpp_lib_array_constexpr                    ------
__cpp_lib_as_const                           ------
__cpp_lib_atomic_is_always_lock_free         201603
__cpp_lib_bool_constant                      ------
__cpp_lib_boyer_moore_searcher               ------
__cpp_lib_byte                               ------
__cpp_lib_chrono                             ------
__cpp_lib_clamp                              ------
__cpp_lib_enable_shared_from_this            ------
__cpp_lib_execution                          ------
__cpp_lib_filesystem                         201703
__cpp_lib_gcd_lcm                            ------
__cpp_lib_hardware_interference_size         ------
__cpp_lib_has_unique_object_representations  ------
__cpp_lib_hypot                              ------
__cpp_lib_incomplete_container_elements      ------
__cpp_lib_invoke                             201411
__cpp_lib_is_aggregate                       ------
__cpp_lib_is_invocable                       ------
__cpp_lib_is_swappable                       ------
__cpp_lib_launder                            ------
__cpp_lib_logical_traits                     ------
__cpp_lib_make_from_tuple                    ------
__cpp_lib_map_try_emplace                    ------
__cpp_lib_math_special_functions             ------
__cpp_lib_memory_resource                    ------
__cpp_lib_node_extract                       201606
__cpp_lib_nonmember_container_access         ------
__cpp_lib_not_fn                             ------
__cpp_lib_optional                           ------
__cpp_lib_parallel_algorithm                 ------
__cpp_lib_raw_memory_algorithms              ------
__cpp_lib_sample                             ------
__cpp_lib_scoped_lock                        ------
__cpp_lib_shared_mutex                       ------
__cpp_lib_shared_ptr_arrays                  ------
__cpp_lib_shared_ptr_weak_type               ------
__cpp_lib_string_view                        ------
__cpp_lib_to_chars                           ------
__cpp_lib_transparent_operators              ------
__cpp_lib_type_trait_variable_templates      ------
__cpp_lib_uncaught_exceptions                ------
__cpp_lib_unordered_map_try_emplace          ------
__cpp_lib_variant                            ------
__cpp_lib_void_t                             201411

C++20 CORE
__cpp_aggregate_paren_init                   ------
__cpp_char8_t                                201811
__cpp_concepts                               201907
__cpp_conditional_explicit                   201806
__cpp_consteval                              ------
__cpp_constexpr                              201907
__cpp_constexpr_dynamic_alloc                201907
__cpp_constexpr_in_decltype                  201711
__cpp_constinit                              201907
__cpp_deduction_guides                       201703
__cpp_designated_initializers                201707
__cpp_generic_lambdas                        201707
__cpp_impl_coroutine                         ------
__cpp_impl_destroying_delete                 201806
__cpp_impl_three_way_comparison              201907
__cpp_init_captures                          201803
__cpp_modules                                ------
__cpp_nontype_template_args                  201411
__cpp_using_enum                             ------

C++20 LIB
__cpp_lib_array_constexpr                    ------
__cpp_lib_assume_aligned                     ------
__cpp_lib_atomic_flag_test                   ------
__cpp_lib_atomic_float                       ------
__cpp_lib_atomic_lock_free_type_aliases      ------
__cpp_lib_atomic_ref                         ------
__cpp_lib_atomic_shared_ptr                  ------
__cpp_lib_atomic_value_initialization        ------
__cpp_lib_atomic_wait                        ------
__cpp_lib_barrier                            ------
__cpp_lib_bind_front                         ------
__cpp_lib_bit_cast                           ------
__cpp_lib_bitops                             ------
__cpp_lib_bounded_array_traits               ------
__cpp_lib_char8_t                            201811
__cpp_lib_chrono                             ------
__cpp_lib_concepts                           ------
__cpp_lib_constexpr_algorithms               ------
__cpp_lib_constexpr_complex                  ------
__cpp_lib_constexpr_dynamic_alloc            ------
__cpp_lib_constexpr_functional               ------
__cpp_lib_constexpr_iterator                 ------
__cpp_lib_constexpr_memory                   ------
__cpp_lib_constexpr_numeric                  ------
__cpp_lib_constexpr_string                   ------
__cpp_lib_constexpr_string_view              ------
__cpp_lib_constexpr_tuple                    ------
__cpp_lib_constexpr_utility                  ------
__cpp_lib_constexpr_vector                   ------
__cpp_lib_coroutine                          ------
__cpp_lib_destroying_delete                  ------
__cpp_lib_endian                             ------
__cpp_lib_erase_if                           201811
__cpp_lib_execution                          ------
__cpp_lib_format                             ------
__cpp_lib_generic_unordered_lookup           ------
__cpp_lib_int_pow2                           ------
__cpp_lib_integer_comparison_functions       ------
__cpp_lib_interpolate                        ------
__cpp_lib_is_constant_evaluated              ------
__cpp_lib_is_layout_compatible               ------
__cpp_lib_is_nothrow_convertible             ------
__cpp_lib_is_pointer_interconvertible        ------
__cpp_lib_jthread                            ------
__cpp_lib_latch                              ------
__cpp_lib_list_remove_return_type            ------
__cpp_lib_math_constants                     ------
__cpp_lib_polymorphic_allocator              ------
__cpp_lib_ranges                             ------
__cpp_lib_remove_cvref                       ------
__cpp_lib_semaphore                          ------
__cpp_lib_shared_ptr_arrays                  ------
__cpp_lib_shift                              ------
__cpp_lib_smart_ptr_for_overwrite            ------
__cpp_lib_source_location                    ------
__cpp_lib_span                               ------
__cpp_lib_ssize                              ------
__cpp_lib_starts_ends_with                   ------
__cpp_lib_string_view                        ------
__cpp_lib_syncbuf                            ------
__cpp_lib_three_way_comparison               ------
__cpp_lib_to_address                         ------
__cpp_lib_to_array                           ------
__cpp_lib_type_identity                      ------
__cpp_lib_unwrap_ref                         ------

C++23 CORE
__cpp_if_consteval                           ------
__cpp_size_t_suffix                          ------

C++23 LIB
__cpp_lib_constexpr_typeinfo                 ------
__cpp_lib_invoke_r                           ------
__cpp_lib_is_scoped_enum                     ------
__cpp_lib_stacktrace                         ------
__cpp_lib_stdatomic_h                        ------
__cpp_lib_string_contains                    ------
__cpp_lib_to_underlying                      ------
__cpp_lib_variant                            ------

ATTRIBUTES
carries_dependency                           200809
deprecated                                   201309
fallthrough                                  201603
likely                                       ------
maybe_unused                                 201603
nodiscard                                    201907
noreturn                                     200809
no_unique_address                            201803
unlikely                                     ------

猜你喜欢

转载自blog.csdn.net/yinminsumeng/article/details/130222837