名前空間
変種
操作

機能テスト (C++20 以降)

From cppreference.com
< cpp

規格では、C++11 以降で導入された C++ 言語およびライブラリの機能に対応するプリプロセッサマクロのセットが定義されています。これらは、当該機能の有無を検知するための、単純で移植性の高い方法として意図されています。

目次

[編集] 属性

__has_cpp_attribute( attribute-token )

attribute-token(マクロ展開後)で指定された名前の属性のサポートをチェックします。

各標準属性について、__has_cpp_attribute が以下の表で与えられる値(その属性が作業草案に追加された年月)に展開されるか、あるいは 0 に展開されるかは、処理系定義です。処理系が推奨される通りに振る舞う(診断メッセージを発行する、クラスレイアウトに影響を与えるなど)場合に限り、表で与えられる値に展開されます。

ベンダー固有の属性の有無は、ゼロ以外の値によって決定されます。

__has_cpp_attribute は、 #if および #elif の式の中で展開できます。 #ifdef #ifndef #elifdef #elifndef(C++23 以降) および defined によっては定義済みマクロとして扱われますが、それ以外の場所では使用できません。

attribute-token 属性 規格 提案文書
assume [[assume]] 202207L (C++23) P1774R8
carries_dependency [[carries_dependency]] 200809L (C++11)
(C++26まで)
N2556
N2643
P3475R2
deprecated [[deprecated]] 201309L (C++14) N3760
fallthrough [[fallthrough]] 201603L (C++17) P0188R1
indeterminate [[indeterminate]] 202403L (C++26) P2795R5
likely [[likely]] 201803L (C++20) P0479R5
maybe_unused [[maybe_unused]] 201603L (C++17) P0212R1
no_unique_address [[no_unique_address]] 201803L (C++20) P0840R2
nodiscard [[nodiscard]] 201603L (C++17) P0189R1
理由付きの [[nodiscard]] 201907L (C++20) P1301R4
noreturn [[noreturn]] 200809L (C++11) N2761
unlikely [[unlikely]] 201803L (C++20) P0479R5
属性の総数: 11

[編集] 言語機能

以下のマクロは、ある言語機能が現在の処理系によって実装されているかどうかを検出するために使用できます。これらはすべての翻訳単位で事前定義されています。

各マクロは、対応する機能が作業草案に含まれた年月に対応する整数リテラルに展開されます。機能が大幅に変更された場合、マクロはそれに応じて更新されます。

マクロ名 機能 規格 提案文書
__cpp_aggregate_bases 基底クラスを持つ集成体クラス 201603L (C++17) P0017R1
__cpp_aggregate_nsdmi デフォルトメンバ初期化子を持つ集成体クラス 201304L (C++14) N3653
__cpp_aggregate_paren_init 直接初期化形式の集成体初期化 201902L (C++20) P0960R3
__cpp_alias_templates エイリアステンプレート 200704L (C++11) N2258
__cpp_aligned_new 過大アライメントされたデータのための動的メモリ確保 201606L (C++17) P0035R4
__cpp_attributes 属性 200809L (C++11) N2761
__cpp_auto_cast auto(x)auto{x} 202110L (C++23) P0849R8
__cpp_binary_literals 2進数リテラル 201304L (C++14) N3472
__cpp_capture_star_this *this[=,*this] による値キャプチャ 201603L (C++17) P0018R3
__cpp_char8_t char8_t 201811L (C++20) P0482R6
char8_t の互換性と移植性の修正(UTF-8 文字列リテラルからの (unsigned) char 配列の初期化を許可) 202207L (C++23)
(DR20)
P2513R4
__cpp_concepts コンセプト 201907L (C++20) P0734R0
P1084R2
P1452R2
条件付きで trivial な特殊メンバ関数 202002L P0848R3
P2493R0
__cpp_conditional_explicit explicit(bool) 201806L (C++20) P0892R2
__cpp_consteval 即時関数 201811L (C++20) P1073R3
consteval を上に伝搬させる 202211L (C++23)
(DR20)
P2564R3
__cpp_constexpr constexpr 200704L (C++11) N2235
緩和された constexprconst でない constexpr メソッド 201304L (C++14) N3652
constexpr ラムダ 201603L (C++17) P0170R1
定数式内での仮想関数呼び出し; constexpr 関数内の try ブロック; 定数式内での dynamic_cast と多相的な typeid; constexpr 関数内での trivial なデフォルト初期化asm-declaration 201907L (C++20) P1064R0
P1002R1
P1327R1
P1331R2
P1668R1
定数評価における共用体のアクティブメンバの変更 202002L P1330R0
P2493R0
constexpr 関数内での非リテラル変数、ラベル、goto 202110L (C++23) P2242R3
constexpr 関数と関数テンプレートに関するいくつかの制約の緩和 202207L P2448R2
constexpr 関数内での静的 constexpr 変数の許可 202211L P2647R1
void* からの constexpr キャスト: constexpr 型消去に向けて 202306L (C++26) P2738R1
constexpr 配置 new 202406L P2747R2
__cpp_constexpr_dynamic_alloc constexpr 関数における動的ストレージ期間の操作 201907L (C++20) P0784R7
__cpp_constexpr_exceptions constexpr 例外 202411L (C++26) P3068R6
__cpp_constexpr_in_decltype 定数評価に必要な場合の関数と変数の定義の生成 201711L (C++20)
(DR11)
P0859R0
__cpp_constinit constinit 201907L (C++20) P1143R2
__cpp_contracts 契約プログラミング 202502L (C++26) P2900R14
__cpp_decltype decltype 200707L (C++11) N2343
__cpp_decltype_auto 通常関数の戻り値型の推論 201304L (C++14) N3638
__cpp_deduction_guides クラステンプレートのテンプレート引数推論 (CTAD) 201703L (C++17) P0091R3
P0512R0
P0620R0
集成体とエイリアスのための CTAD 201907L (C++20) P1814R0
P1816R0
__cpp_delegating_constructors 委譲コンストラクタ 200604L (C++11) N1986
__cpp_deleted_function メッセージ付きの deleted 関数定義 (= delete("should have a reason");) 202403L (C++26) P2573R2
__cpp_designated_initializers 指示付き初期化子 201707L (C++20) P0329R4
__cpp_enumerator_attributes 列挙子に対する属性 201411L (C++17) N4266
__cpp_explicit_this_parameter 明示的なオブジェクトパラメータ 202110L (C++23) P0847R7
__cpp_fold_expressions 畳み込み式 201603L (C++17) N4295
P0036R0
畳み込み式を含む制約の順序付け 202406L (C++26) P2963R3
__cpp_generic_lambdas ジェネリックラムダ式 201304L (C++14) N3649
ジェネリックラムダの明示的なテンプレートパラメータリスト 201707L (C++20) P0428R2
__cpp_guaranteed_copy_elision 単純化された値カテゴリによる保証されたコピー省略 201606L (C++17) P0135R1
__cpp_hex_float 16進浮動小数点リテラル 201603L (C++17) P0245R1
__cpp_if_consteval if consteval 202106L (C++23) P1938R3
__cpp_if_constexpr if constexpr 201606L (C++17) P0292R2
__cpp_impl_coroutine コルーチン (コンパイラサポート) 201902L (C++20) P0912R5
LWG3393
__cpp_impl_destroying_delete 破棄operator delete (コンパイラサポート) 201806L (C++20) P0722R3
__cpp_impl_three_way_comparison 三方比較 (コンパイラサポート) 201907L (C++20) P0515R3
P0768R1
P1185R2
P1630R1
__cpp_implicit_move より単純な暗黙のムーブ 202207L (C++23) P2266R3
__cpp_inheriting_constructors 継承コンストラクタ 200802L (C++11) N2540
継承コンストラクタの再定義: 継承コンストラクタの新しい仕様 (DR1941 など) 201511L (C++17)
(DR11)
P0136R1
__cpp_init_captures ラムダの初期化キャプチャ 201304L (C++14) N3648
ラムダの初期化キャプチャにおけるパック展開の許可 201803L (C++20) P0780R2
__cpp_initializer_lists リスト初期化std::initializer_list 200806L (C++11) N2672
__cpp_inline_variables インライン変数 201606L (C++17) P0386R2
__cpp_lambdas ラムダ式 200907L (C++11) N2927
__cpp_modules モジュール 201907L (C++20) P1103R3
P1811R0
__cpp_multidimensional_subscript 多次元添字演算子 202110L (C++23) P2128R6
静的 operator[] 202211L P2589R1
__cpp_named_character_escapes 名前付きユニバーサル文字エスケープ 202207L (C++23) P2071R2
__cpp_namespace_attributes 名前空間に対する属性 201411L (C++17) N4266
__cpp_noexcept_function_type 例外仕様を型システムの一部にする 201510L (C++17) P0012R1
__cpp_nontype_template_args すべての非型テンプレート引数に対する定数評価の許可 201411L (C++17) N4268
非型テンプレートパラメータにおけるクラス型と浮動小数点型 201911L (C++20) P1907R1
__cpp_nontype_template_parameter_auto auto を用いた非型テンプレートパラメータの宣言 201606L (C++17) P0127R2
__cpp_nsdmi 非静的データメンバ初期化子 200809L (C++11) N2756
__cpp_pack_indexing パックインデックス 202311L (C++26) P2662R3
__cpp_placeholder_variables 名前のない素敵なプレースホルダー 202306L (C++26) P2169R4
__cpp_pp_embed #embed 202502L (C++26) P1967R14
__cpp_range_based_for 範囲 for ループ 200907L (C++11) N2930
begin/end の型が異なる範囲 for ループ 201603L (C++17) P0184R0
範囲ベース for での寿命延長 202211L (C++23) P2644R1
P2718R0
CWG2659
__cpp_raw_strings 生文字列リテラル 200710L (C++11) N2442
__cpp_ref_qualifiers ref 修飾子 200710L (C++11) N2439
__cpp_return_type_deduction 通常関数の戻り値型の推論 201304L (C++14) N3638
__cpp_rvalue_references 右辺値参照 200610L (C++11) N2118
__cpp_size_t_suffix std::size_t とその符号付き版のリテラルサフィックス 202011L (C++23) P0330R8
__cpp_sized_deallocation サイズ付きデアロケーション 201309L (C++14) N3778
__cpp_static_assert static_assert 200410L (C++11) N1720
単一引数の static_assert 201411L (C++17) N3928
ユーザー生成の static_assert メッセージ 202306L (C++26) P2741R3
__cpp_static_call_operator 静的 operator() 202207L (C++23) P1169R4
__cpp_structured_bindings 構造化束縛 201606L (C++17) P0217R3
構造化束縛のための属性 202403L (C++26) P0609R3
条件としての構造化束縛宣言 202406L P0963R3
構造化束縛パックを導入できる 202411L P1061R10
__cpp_template_parameters コンセプトおよび変数テンプレートのテンプレートパラメータ 202502L (C++26) P2841R7
__cpp_template_template_args テンプレートテンプレート引数のマッチング 201611L (C++17) P0522R0
__cpp_threadsafe_static_init 並行性を持つ動的初期化と破棄 200806L (C++11) N2660
__cpp_trivial_relocatability Trivial な再配置可能性 202502L (C++26) P2786R13
__cpp_trivial_union Trivial な共用体 202502L (C++26) P3074R7
__cpp_unicode_characters 新しい文字型 (char16_tchar32_t) 200704L (C++11) N2249
__cpp_unicode_literals Unicode文字列リテラル 200710L (C++11) N2442
__cpp_user_defined_literals ユーザー定義リテラル 200809L (C++11) N2765
__cpp_using_enum using enum 201907L (C++20) P1099R5
__cpp_variable_templates 変数テンプレート 201304L (C++14) N3651
__cpp_variadic_friend 可変引数フレンド宣言 202403L (C++26) P2893R3
__cpp_variadic_templates 可変引数テンプレート 200704L (C++11) N2242
__cpp_variadic_using using-declarations におけるパック展開 201611L (C++17) P0195R2
マクロの総数: 76

[編集] ライブラリ機能

以下のマクロは、標準ライブラリ機能が現在の処理系によって実装されているかどうかを検出するために使用できます。言語機能テストマクロとは異なり、これらは事前定義されていません。代わりに、ヘッダ <version> によって提供されます。

各ライブラリ機能テストマクロは、関連する標準ライブラリコンポーネントを提供するヘッダによっても提供されます。これらのマクロを提供するヘッダの完全なリストについては、ライブラリ機能テストマクロを参照してください。

各マクロは、対応する機能が作業草案に含まれた年月に対応する整数リテラルに展開されます。機能が大幅に変更された場合、マクロはそれに応じて更新されます。

マクロ名 機能 規格 提案文書
__cpp_lib_adaptor_iterator_pair_constructor std::stackstd::queue のためのイテレータペアコンストラクタ 202106L (C++23) P1425R4
__cpp_lib_addressof_constexpr Constexpr な std::addressof 201603L (C++17) LWG2296
__cpp_lib_algorithm_default_value_type アルゴリズムに対するリスト初期化の有効化 202403L (C++26) P2248R8
P3217R0
__cpp_lib_algorithm_iterator_requirements 非 Ranges アルゴリズムへの入力としての Ranges イテレータ 202207L (C++23) P2408R5
__cpp_lib_aligned_accessor std::aligned_accessor: ポインタの過剰アライメントを表現する std::mdspan アクセッサ 202411L (C++26) P2897R7
__cpp_lib_allocate_at_least アロケータインタフェースにおけるサイズフィードバック、例: std::allocator::allocate_at_least, std::allocator_traits::allocate_at_least 202302L (C++23) P0401R6
P2652R2
LWG3887
__cpp_lib_allocator_traits_is_always_equal std::allocator_traits::is_always_equalnoexcept のクリーンアップ 201411L (C++17) N4258
__cpp_lib_any std::any 201606L (C++17) P0220R1
P0032R3
__cpp_lib_apply std::apply 201603L (C++17) P0220R1
__cpp_lib_array_constexpr std::reverse_iteratorstd::move_iteratorstd::array および 範囲アクセスの constexpr 化 201603L (C++17) P0031R0
ConstexprIterator; std::arrayconstexpr 比較; その他の constexpr 対応 (std::array::fill など) 201811L (C++20) P0858R0
LWG3257
P1023R0
P1032R1
__cpp_lib_as_const std::as_const 201510L (C++17) P0007R1
__cpp_lib_associative_heterogeneous_erasure 連想コンテナ非順序連想コンテナにおける異種型の削除 202110L (C++23) P2077R3
__cpp_lib_associative_heterogeneous_insertion 順序付きおよび非順序連想コンテナにおける残りのメンバ関数に対する異種型オーバーロード 202306L (C++26) P2363R5
__cpp_lib_assume_aligned std::assume_aligned 201811L (C++20) P1007R3
__cpp_lib_atomic_flag_test std::atomic_flag::test 201907L (C++20) P1135R6
__cpp_lib_atomic_float 浮動小数点アトミック 201711L (C++20) P0020R6
__cpp_lib_atomic_is_always_lock_free Constexpr std::atomic<T>::is_always_lock_free 201603L (C++17) P0152R1
__cpp_lib_atomic_lock_free_type_aliases アトミックロックフリー整数型 (std::atomic_signed_lock_free, std::atomic_unsigned_lock_free) 201907L (C++20) P1135R6
__cpp_lib_atomic_min_max アトミックな最小値/最大値 (std::atomic::fetch_min, std::atomic::fetch_max, etc) 202403L (C++26) P0493R5
__cpp_lib_atomic_ref std::atomic_ref 201806L (C++20) P0019R8
std::atomic_ref::address() 202411L (C++26) P2835R7
__cpp_lib_atomic_shared_ptr std::atomic<std::shared_ptr> 201711L (C++20) P0718R2
__cpp_lib_atomic_value_initialization アトミック初期化の修正 (デフォルトで std::atomic を値初期化する) 201911L (C++20) P0883R2
__cpp_lib_atomic_wait 効率的な std::atomic 待機 201907L (C++20) P1135R6
__cpp_lib_barrier std::barrier 201907L (C++20) P1135R6
std::barrier のフェーズ完了保証 202302L (C++23) P2588R3
__cpp_lib_bind_back std::bind_back 202202L (C++23) P2387R3
呼び出し可能オブジェクトを非型テンプレート引数として std::bind_back に渡すことを許可 202306L (C++26) P2714R1
__cpp_lib_bind_front std::bind_front 201907L (C++20) P0356R5
P1651R0
呼び出し可能オブジェクトを非型テンプレート引数として std::bind_front に渡すことを許可 202306L (C++26) P2714R1
__cpp_lib_bit_cast std::bit_cast 201806L (C++20) P0476R2
__cpp_lib_bitops ビット操作 201907L (C++20) P0553R4
__cpp_lib_bitset std::bitsetstd::string_view の連携 202306L (C++26) P2697R1
__cpp_lib_bool_constant std::bool_constant 201505L (C++17) N4389
__cpp_lib_bounded_array_traits std::is_bounded_array, std::is_unbounded_array 201902L (C++20) P1357R1
__cpp_lib_boyer_moore_searcher サーチャー 201603L (C++17) P0220R1
__cpp_lib_byte std::byte 201603L (C++17) P0298R3
__cpp_lib_byteswap std::byteswap 202110L (C++23) P1272R4
__cpp_lib_char8_t char8_t のライブラリサポート 201907L (C++20) P0482R6
P1423R3
__cpp_lib_chrono std::chrono::durationstd::chrono::time_point のための丸め関数 201510L (C++17) P0092R1
std::chrono::durationstd::chrono::time_point の全メンバ関数の constexpr 化 201611L P0505R0
カレンダータイムゾーン 201907L (C++20) P0355R7
P1466R3
std::chrono 値クラスのためのハッシュサポート 202306L (C++26) P2592R3
__cpp_lib_chrono_udls 時間型のユーザー定義リテラル 201304L (C++14) N3642
__cpp_lib_clamp std::clamp 201603L (C++17) P0025R1
__cpp_lib_common_reference std::reference_wrapperstd::common_reference_t を参照型にする 202302L (C++23) P2655R3
__cpp_lib_common_reference_wrapper std::reference_wrapperstd::common_reference_t を参照型にする 202302L (C++23) P2655R3
__cpp_lib_complex_udls std::complex のためのユーザー定義リテラル 201309L (C++14) N3779
__cpp_lib_concepts 標準ライブラリコンセプト 202002L (C++20) P0898R3
P1754R1
P1964R2
equality_comparable_withtotally_ordered_withthree_way_comparable_with のためのムーブオンリー型 202207L (C++23) P2404R3
__cpp_lib_constexpr_algorithms アルゴリズムの constexpr 化 201806L (C++20) P0202R3
P0879R0
LWG3256
LWG3792
Constexpr 安定ソート 202306L (C++26) P2562R1
__cpp_lib_constexpr_atomic constexpr std::atomicstd::atomic_ref 202411L (C++26) P3309R3
__cpp_lib_constexpr_bitset より constexprstd::bitset 202207L (C++23) P2417R2
__cpp_lib_constexpr_charconv 整数型に対する std::to_charsstd::from_chars の constexpr 化 202207L (C++23) P2291R3
__cpp_lib_constexpr_cmath <cmath><cstdlib> の数学関数の constexpr 化 202202L (C++23) P0533R9
<cmath> のさらなる constexpr 202306L (C++26) P1383R2
__cpp_lib_constexpr_complex std::complex の constexpr 化 201711L (C++20) P0415R1
<complex> のさらなる constexpr 202306L (C++26) P1383R2
__cpp_lib_constexpr_containers より多くの constexpr コンテナとアダプタ 202502L (C++26) P3372R2
__cpp_lib_constexpr_dynamic_alloc std::allocator と関連ユーティリティの constexpr 化 201907L (C++20) P0784R7
__cpp_lib_constexpr_exceptions 例外型の constexpr 化、例: std::bad_alloc, std::bad_cast など 202411L (C++26) P3068R6
例外型のさらなる constexpr 202502L P3378R2
__cpp_lib_constexpr_functional その他の constexpr 対応 (std::default_searcher); constexpr INVOKE 201907L (C++20) P1032R1
P1065R2
__cpp_lib_constexpr_inplace_vector 非 trivial 型のための constexpr std::inplace_vector 202502L (C++26) P3074R7
__cpp_lib_constexpr_iterator その他の constexpr 対応 (std::insert_iterator など) 201811L (C++20) P1032R1
__cpp_lib_constexpr_memory std::pointer_traits の constexpr 化 201811L (C++20) P1006R1
Constexpr な std::unique_ptr 202202L (C++23) P2273R3
__cpp_lib_constexpr_new Constexpr な配置 new 202406L (C++26) P2747R2
__cpp_lib_constexpr_numeric <numeric> 内のアルゴリズムの constexpr 化 201911L (C++20) P1645R1
__cpp_lib_constexpr_string constexpr std::char_traits 201611L (C++17) P0426R1
constexpr std::string 201907L (C++20) P0980R1
__cpp_lib_constexpr_string_view その他の constexpr 対応 (std::string_view::copy) 201811L (C++20) P1032R1
__cpp_lib_constexpr_tuple その他の constexpr 対応 (std::tuple::operator= など) 201811L (C++20) P1032R1
__cpp_lib_constexpr_typeinfo std::type_info::operator== の constexpr 化 202106L (C++23) P1328R1
__cpp_lib_constexpr_utility その他の constexpr 対応 (std::pair::operator= など) 201811L (C++20) P1032R1
__cpp_lib_constexpr_vector std::vector の constexpr 化 201907L (C++20) P1004R2
__cpp_lib_constrained_equality std::pairstd::tuplestd::optionalstd::variant のための制約付き関係演算子 202403L (C++26) P2944R3
std::expected等価比較演算子の制約 202411L P3379R0
__cpp_lib_containers_ranges コンテナと文字列のためのRanges 対応構築と挿入 202202L (C++23) P1206R7
__cpp_lib_contracts <contracts>: 契約プログラミングのサポート 202502L (C++26) P2900R14
__cpp_lib_copyable_function std::copyable_function 202306L (C++26) P2548R6
__cpp_lib_coroutine コルーチン (ライブラリサポート) 201902L (C++20) P0912R5
LWG3393
__cpp_lib_debugging <debugging>: デバッグサポート 202311L (C++26) P2546R5
置換可能な std::is_debugger_present 202403L P2810R4
__cpp_lib_destroying_delete 破棄operator delete (ライブラリサポート) 201806L (C++20) P0722R3
__cpp_lib_enable_shared_from_this std::enable_shared_from_this::weak_from_this 201603L (C++17) P0033R1
__cpp_lib_endian std::endian 201907L (C++20) P0463R1
P1612R1
__cpp_lib_erase_if 統一的なコンテナ要素の削除 202002L (C++20) P1209R0
P1115R3
__cpp_lib_exchange_function std::exchange 201304L (C++14) N3668
__cpp_lib_execution 実行ポリシー 201603L (C++17) P0024R2
std::execution::unsequenced_policy 201902L (C++20) P1001R2
__cpp_lib_expected クラステンプレート std::expected 202202L (C++23) P0323R12
std::expected のためのモナド関数 202211L P2505R5
__cpp_lib_filesystem ファイルシステムライブラリ 201703L (C++17) P0218R1
P0219R1
P0392R0
P0317R1
__cpp_lib_flat_map std::flat_mapstd::flat_multimap 202207L (C++23) P0429R9
__cpp_lib_flat_set std::flat_setstd::flat_multiset 202207L (C++23) P1222R4
LWG3751
__cpp_lib_format テキストフォーマット 201907L (C++20) P0645R10
P1361R2
P1652R1
コンパイル時書式文字列チェック; std::vformat_to のパラメータ化の削減 202106L (C++23)
(DR20)
P2216R3
chrono フォーマッタにおけるロケール処理の修正; const フォーマット可能でない型のサポート 202110L P2372R3
P2418R2
std::basic_format_string の公開; chrono 型のローカライズされたフォーマットにおけるエンコーディング処理の明確化 202207L (C++23) P2419R2
P2508R1
ポインタのフォーマット 202304L (C++26) P2510R3
フォーマット引数の型チェック 202305L P2757R3
メンバ visit 202306L P2637R3
実行時書式文字列 202311L P2918R2
__cpp_lib_format_path std::filesystem::path のフォーマット 202403L (C++26) P2845R8
__cpp_lib_format_ranges Ranges のフォーマット 202207L (C++23) P2286R8
P2585R1
LWG3750
__cpp_lib_format_uchar コードユニットの整数としてのフォーマットの修正 202311L (C++26) P2909R4
__cpp_lib_formatters std::thread::idstd::stacktrace のフォーマット 202302L (C++23) P2693R1
__cpp_lib_forward_like std::forward_like 202207L (C++23) P2445R1
__cpp_lib_freestanding_algorithm <algorithm> 内のフリースタンディング機能 202311L (C++26) P2407R5
__cpp_lib_freestanding_array std::array の一部をフリースタンディングにする 202311L (C++26) P2407R5
__cpp_lib_freestanding_char_traits フリースタンディング std::char_traits 202306L (C++26) P2338R4
__cpp_lib_freestanding_charconv <charconv> 内のフリースタンディング機能 202306L (C++26) P2338R4
__cpp_lib_freestanding_cstdlib <cstdlib> 内のフリースタンディング機能 202306L (C++26) P2338R4
__cpp_lib_freestanding_cstring <cstring> 内のフリースタンディング機能 202306L (C++26) P2338R4
フリースタンディング機能から std::strtok を削除 202311L P2937R0
__cpp_lib_freestanding_cwchar <cwchar> 内のフリースタンディング機能 202306L (C++26) P2338R4
__cpp_lib_freestanding_errc フリースタンディング std::errc 202306L (C++26) P2338R4
__cpp_lib_freestanding_expected std::expected の一部をフリースタンディングにする 202311L (C++26) P2833R2
__cpp_lib_freestanding_feature_test_macros フリースタンディング機能テストマクロのサポート 202306L (C++26) P2198R7
__cpp_lib_freestanding_functional <functional> 内のフリースタンディング機能 202306L (C++26) P2198R7
__cpp_lib_freestanding_iterator <iterator> 内のフリースタンディング機能 202306L (C++26) P2198R7
__cpp_lib_freestanding_mdspan フリースタンディング std::mdspan 202311L (C++26) P2833R2
__cpp_lib_freestanding_memory <memory> 内のフリースタンディング機能 202306L (C++26) P2198R7
__cpp_lib_freestanding_numeric <numeric> 内のフリースタンディング機能 (飽和演算) 202311L (C++26) P0543R3
__cpp_lib_freestanding_operator_new operator new の定義 (フリースタンディング実装では任意) 202306L (C++26) P2198R7
__cpp_lib_freestanding_optional std::optional の一部をフリースタンディングにする 202311L (C++26) P2407R5
__cpp_lib_freestanding_ranges <ranges> 内のフリースタンディング機能 202306L (C++26) P2198R7
__cpp_lib_freestanding_ratio <ratio> 内のフリースタンディング機能 202306L (C++26) P2198R7
__cpp_lib_freestanding_string_view std::string_view の一部をフリースタンディングにする 202311L (C++26) P2407R5
__cpp_lib_freestanding_tuple <tuple> 内のフリースタンディング機能 202306L (C++26) P2198R7
__cpp_lib_freestanding_utility <utility> 内のフリースタンディング機能 202306L (C++26) P2198R7
__cpp_lib_freestanding_variant std::variant の一部をフリースタンディングにする 202311L (C++26) P2407R5
__cpp_lib_fstream_native_handle ファイルストリームからのネイティブハンドルの取得 202306L (C++26) P1759R6
__cpp_lib_function_ref std::function_ref: 型消去された呼び出し可能参照 202306L (C++26) P0792R14
__cpp_lib_gcd_lcm std::gcd, std::lcm 201606L (C++17) P0295R0
__cpp_lib_generator std::generator: Ranges 用の同期コルーチンジェネレータ 202207L (C++23) P2502R2
__cpp_lib_generic_associative_lookup 連想コンテナにおける異種型の比較ルックアップ 201304L (C++14) N3657
__cpp_lib_generic_unordered_lookup 非順序連想コンテナにおける異種型の比較ルックアップ 201811L (C++20) P0919R3
__cpp_lib_hardware_interference_size Constexpr std::hardware_{constructive, destructive}_interference_size 201703L (C++17) P0154R1
__cpp_lib_hive <hive>: 削除された要素のメモリ位置を再利用するバケットベースのコンテナ 202502L (C++26) P0447R28
__cpp_lib_has_unique_object_representations std::has_unique_object_representations 201606L (C++17) P0258R2
__cpp_lib_hazard_pointer <hazard_pointer>: ハザードポインタ 202306L (C++26) P2530R3
__cpp_lib_hypot std::hypot の 3 引数オーバーロード 201603L (C++17) P0030R1
__cpp_lib_incomplete_container_elements std::forward_list, std::list, std::vector のための最小限の不完全型サポート 201505L (C++17) N4510
__cpp_lib_indirect std::indirect 202502L (C++26) P3019R13
__cpp_lib_inplace_vector std::inplace_vector: 固定容量を持つ動的リサイズ可能なベクタ (インプレースストレージ) 202406L (C++26) P0843R14
__cpp_lib_int_pow2 整数の2のべき乗操作 (std::has_single_bit, std::bit_ceil, std::bit_floor, std::bit_width) 202002L (C++20) P0556R3
P1956R1
__cpp_lib_integer_comparison_functions 整数比較関数 202002L (C++20) P0586R2
__cpp_lib_integer_sequence コンパイル時整数シーケンス 201304L (C++14) N3658
__cpp_lib_integral_constant_callable std::integral_constant::operator() 201304L (C++14) N3545
__cpp_lib_interpolate std::lerp, std::midpoint 201902L (C++20) P0811R3
__cpp_lib_invoke std::invoke 201411L (C++17) N4169
__cpp_lib_invoke_r std::invoke_r 202106L (C++23) P2136R3
__cpp_lib_ios_noreplace fstream の排他モードのサポート 202207L (C++23) P2467R1
__cpp_lib_is_aggregate std::is_aggregate 201703L (C++17) LWG2911
__cpp_lib_is_constant_evaluated std::is_constant_evaluated 201811L (C++20) P0595R2
__cpp_lib_is_final std::is_final 201402L (C++14) LWG2112
__cpp_lib_is_implicit_lifetime std::is_implicit_lifetime 202302L (C++23) P2674R1
__cpp_lib_is_invocable std::is_invocable, std::invoke_result 201703L (C++17) P0604R0
__cpp_lib_is_layout_compatible std::is_layout_compatible 201907L (C++20) P0466R5
__cpp_lib_is_nothrow_convertible std::is_convertible 201806L (C++20) P0758R1
LWG3356
__cpp_lib_is_null_pointer std::is_null_pointer 201309L (C++14)
(DR11)
LWG2247
__cpp_lib_is_pointer_interconvertible ポインタ相互変換可能性特性: std::is_pointer_interconvertible_with_class, std::is_pointer_interconvertible_base_of 201907L (C++20) P0466R5
__cpp_lib_is_scoped_enum std::is_scoped_enum 202011L (C++23) P1048R1
__cpp_lib_is_sufficiently_aligned std::is_sufficiently_aligned: ポインタのアライメント事前条件をチェックする 202411L (C++26) P2897R7
__cpp_lib_is_swappable (nothrow-)swappable traits 201603L (C++17) P0185R1
__cpp_lib_is_virtual_base_of std::is_virtual_base_of: 仮想基底クラスを検出するための型特性 202406L (C++26) P2985R0
__cpp_lib_is_within_lifetime 共用体の選択肢がアクティブであるかのチェック (std::is_within_lifetime) 202306L (C++26) P2641R4
__cpp_lib_jthread ストップトークン合流スレッド 201911L (C++20) P0660R10
P1869R1
__cpp_lib_latch std::latch 201907L (C++20) P1135R6
__cpp_lib_launder CWG issue 1776: 参照メンバを含むクラスオブジェクトの置換 (std::launder) 201606L (C++17) P0137R1
__cpp_lib_linalg BLAS に基づく自由関数線形代数インターフェース 202311L (C++26) P1673R13
__cpp_lib_list_remove_return_type std::forward_liststd::listremove(), remove_if(), unique() の戻り値型の変更 201806L (C++20) P0646R1
__cpp_lib_logical_traits 型特性に対する論理演算 201510L (C++17) P0013R1
__cpp_lib_make_from_tuple std::make_from_tuple 201606L (C++17) P0209R2
__cpp_lib_make_reverse_iterator std::make_reverse_iterator 201402L (C++14) LWG2285
__cpp_lib_make_unique std::make_unique 201304L (C++14) N3656
__cpp_lib_map_try_emplace std::map::try_emplace, std::map::insert_or_assign 201411L (C++17) N4279
__cpp_lib_math_constants 数学定数 201907L (C++20) P0631R8
__cpp_lib_math_special_functions 数学特殊関数 201603L (C++17) P0226R1
__cpp_lib_mdspan std::mdspan 202207L (C++23) P0009R18
P2599R2
P2604R0
P2613R1
std::mdspan のための std::dims 202406L (C++26) P2389R2
__cpp_lib_memory_resource std::pmr::memory_resource 201603L (C++17) P0220R1
__cpp_lib_modules 標準ライブラリモジュール stdstd.compat 202207L (C++23) P2465R3
__cpp_lib_move_iterator_concept std::move_iterator<T*> をランダムアクセスイテレータにする 202207L (C++23) P2520R0
__cpp_lib_move_only_function std::move_only_function 202110L (C++23) P0288R9
__cpp_lib_node_extract マップとセットのスプライシング (std::map::extract, std::map::merge, insert(node_type), など) 201606L (C++17) P0083R3
__cpp_lib_nonmember_container_access std::size, std::data and std::empty 201411L (C++17) N4280
__cpp_lib_not_fn std::not_fn 201603L (C++17) P0005R4
呼び出し可能オブジェクトを非型テンプレート引数として std::not_fn に渡すことを許可 202306L (C++26) P2714R1
__cpp_lib_null_iterators ヌル LegacyForwardIterators 201304L (C++14) N3644
__cpp_lib_optional std::optional 201606L (C++17) P0220R1
P0032R3
P0307R2
完全に constexprstd::optional 202106L (C++23)
(DR20)
P2231R1
std::optional におけるモナド操作 202110L (C++23) P0798R8
LWG3621
__cpp_lib_optional_range_support std::optional の range サポート 202406L (C++26) P3168R2
__cpp_lib_out_ptr std::out_ptr, std::inout_ptr 202106L (C++23) P1132R8
フリースタンディング std::out_ptr, std::inout_ptr 202311L (C++26) P2833R2
__cpp_lib_parallel_algorithm 並列アルゴリズム 201603L (C++17) P0024R2
__cpp_lib_polymorphic std::polymorphic 202502L (C++26) P3019R13
__cpp_lib_polymorphic_allocator ボキャブラリ型としての std::pmr::polymorphic_allocator<> 201902L (C++20) P0339R6
LWG3437
__cpp_lib_print 書式付き出力 202207L (C++23) P2093R14
std::print の効率的な実装を許可する 202403L (C++26)
(DR23)
P3107R5
P3235R3
std::println による空行の出力 202403L (C++26) P3142R0
__cpp_lib_quoted_string_io std::quoted 201304L (C++14) N3654
__cpp_lib_philox_engine std::philox_engine: カウンタベースの乱数エンジン 202406L (C++26) P2075R6
__cpp_lib_ranges Ranges ライブラリ制約付きアルゴリズム 201911L (C++20) P0896R4
P1035R7
P1716R3
デフォルト初期化可能view 202106L (C++23)
(DR20)
P2325R3
所有権を持つビュー 202110L P2415R2
std::ranges::range_adaptor_closure 202202L (C++23) P2387R3
ムーブオンリー型を許容するためのレンジアダプタの緩和 202207L P2494R2
ranges::begin, ranges::end, ranges::rbegin, ranges::rend, ranges::size における「毒薬」オーバーロードの削除 202211L P2602R2
特定のプロジェクションを許容するための ranges の緩和 202302L P2609R3
間接的に呼び出し可能なコンセプトからの共通参照要件の削除 202406L (C++26)
(DR20)
P2997R1
__cpp_lib_ranges_as_const std::const_iterator, std::ranges::as_const_view 202207L (C++23) P2278R4
std::basic_const_iterator が基になる型の変換可能性に従うようにする 202311L (C++26) P2836R1
__cpp_lib_ranges_as_rvalue std::ranges::as_rvalue_view 202207L (C++23) P2446R2
__cpp_lib_ranges_cache_latest std::ranges::cache_latest_view 202411L (C++26) P3138R5
__cpp_lib_ranges_cartesian_product std::ranges::cartesian_product_view 202207L (C++23) P2374R4
P2540R1
__cpp_lib_ranges_chunk std::ranges::chunk_view 202202L (C++23) P2442R1
__cpp_lib_ranges_chunk_by std::ranges::chunk_by_view 202202L (C++23) P2443R1
__cpp_lib_ranges_concat std::ranges::concat_view 202403L (C++26) P2542R8
__cpp_lib_ranges_contains std::ranges::contains 202207L (C++23) P2302R4
__cpp_lib_ranges_enumerate std::ranges::enumerate_view 202302L (C++23) P2164R9
__cpp_lib_ranges_find_last std::ranges::find_last, std::ranges::find_last_if, std::ranges::find_last_if_not 202207L (C++23) P1223R5
LWG3807
__cpp_lib_ranges_fold std::ranges 畳み込みアルゴリズム 202207L (C++23) P2322R6
__cpp_lib_ranges_generate_random 乱数生成のためのベクタ API (std::ranges::generate_random) 202403L (C++26) P1068R11
__cpp_lib_ranges_iota std::ranges::iota 202202L (C++23) P2440R1
__cpp_lib_ranges_join_with std::ranges::join_with_view 202202L (C++23) P2441R2
__cpp_lib_ranges_repeat std::ranges::repeat_view 202207L (C++23) P2474R2
__cpp_lib_ranges_reserve_hint std::ranges::approximately_sized_rangestd::ranges::reserve_hint 202502L (C++26) P2846R6
__cpp_lib_ranges_slide std::ranges::slide_view 202202L (C++23) P2442R1
__cpp_lib_ranges_starts_ends_with std::ranges::starts_with, std::ranges::ends_with 202106L (C++23) P1659R3
__cpp_lib_ranges_stride std::ranges::stride_view 202207L (C++23) P1899R3
__cpp_lib_ranges_to_container std::ranges::to 202202L (C++23) P1206R7
__cpp_lib_ranges_to_input std::ranges::to_input_view 202502L (C++26) P3137R3
__cpp_lib_ranges_zip std::ranges::zip_view, std::ranges::zip_transform_view, std::ranges::adjacent_view, std::ranges::adjacent_transform_view 202110L (C++23) P2321R2
__cpp_lib_ratio 新しい 2022 年の SI 接頭辞の追加 202306L (C++26) P2734R0
__cpp_lib_raw_memory_algorithms メモリ管理ツールの拡張 201606L (C++17) P0040R3
特殊なメモリアルゴリズムconstexpr 202411L (C++26) P3508R0
P3369R0
__cpp_lib_rcu <rcu>: Read-Copy Update (RCU) 202306L (C++26) P2545R4
__cpp_lib_reference_from_temporary std::reference_constructs_from_temporarystd::reference_converts_from_temporary 202202L (C++23) P2255R2
__cpp_lib_reference_wrapper std::reference_wrapper のための比較 202403L (C++26) P2944R3
__cpp_lib_remove_cvref std::remove_cvref 201711L (C++20) P0550R2
__cpp_lib_result_of_sfinae std::result_ofSFINAE 201210L (C++14) N3462
__cpp_lib_robust_nonmodifying_seq_ops 非変更シーケンス操作をより堅牢にする (std::mismatch, std::equal, std::is_permutation の 2 範囲オーバーロード) 201304L (C++14) N3671
__cpp_lib_sample std::sample 201603L (C++17) P0220R1
__cpp_lib_saturation_arithmetic 飽和演算 202311L (C++26) P0543R3
__cpp_lib_scoped_lock std::scoped_lock 201703L (C++17) P0156R2
__cpp_lib_semaphore std::counting_semaphore, std::binary_semaphore 201907L (C++20) P1135R6
__cpp_lib_senders std::execution: 実行制御の Sender-receiver モデル 202406L (C++26) P2300R10
__cpp_lib_shared_mutex std::shared_mutex (時間制限なし) 201505L (C++17) N4508
__cpp_lib_shared_ptr_arrays std::shared_ptr<T[]> 201611L (C++17) P0497R0
std::make_shared の配列サポート 201707L (C++20) P0674R1
__cpp_lib_shared_ptr_weak_type shared_ptr::weak_type 201606L (C++17) P0163R0
__cpp_lib_shared_timed_mutex std::shared_timed_mutex 201402L (C++14) N3891
__cpp_lib_shift std::shift_leftstd::shift_right 201806L (C++20) P0769R2
std::ranges::shift_leftstd::ranges::shift_right 202202L (C++23) P2440R1
__cpp_lib_simd <simd>: データ並列型 202411L (C++26) P1928R15
__cpp_lib_smart_ptr_for_overwrite デフォルト初期化によるスマートポインタ生成 (std::allocate_shared_for_overwrite, std::make_shared_for_overwrite, std::make_unique_for_overwrite) 202002L (C++20) P1020R1
P1973R1
__cpp_lib_smart_ptr_owner_equality 非順序連想コンテナのキーとして std::weak_ptr の使用を有効にする 202306L (C++26) P1901R2
__cpp_lib_source_location ソースコード情報キャプチャ (std::source_location) 201907L (C++20) P1208R6
__cpp_lib_span std::span 202002L (C++20) P0122R7
LWG3274
P1024R3
P1976R2
std::span の一部をフリースタンディングにする 202311L (C++26) P2821R5
P2833R2
__cpp_lib_span_initializer_list 初期化子リストからの std::span の構築 202311L (C++26) P2447R6
__cpp_lib_spanstream std::spanbuf, std::spanstream 202106L (C++23) P0448R4
__cpp_lib_ssize std::ssize と符号なし std::span::size 201902L (C++20) P1227R2
__cpp_lib_sstream_from_string_view std::stringstreamstd::string_view の連携 202306L (C++26) P2495R3
__cpp_lib_stacktrace スタックトレースライブラリ 202011L (C++23) P0881R7
__cpp_lib_start_lifetime_as 明示的な生存期間管理 (std::start_lifetime_as) 202207L (C++23) P2590R2
__cpp_lib_starts_ends_with 文字列の接頭辞と接尾辞のチェック (std::stringstd::string_viewstarts_with()ends_with()) 201711L (C++20) P0457R2
__cpp_lib_stdatomic_h C アトミック操作のための互換ヘッダ 202011L (C++23) P0943R6
__cpp_lib_string_contains std::basic_stringstd::basic_string_view のための contains() 202011L (C++23) P1679R3
__cpp_lib_string_resize_and_overwrite std::basic_string::resize_and_overwrite 202110L (C++23) P1072R10
__cpp_lib_string_udls 文字列型のためのユーザー定義リテラル 201304L (C++14) N3642
__cpp_lib_string_view std::string_view 201606L (C++17) P0220R1
P0254R2
ConstexprIterator 201803L (C++20) P0858R0
LWG3257
std::stringstd::string_view連結 202403L (C++26) P2591R5
__cpp_lib_submdspan std::submdspan 202306L (C++26) P2630R4
パディングされた mdspan レイアウト 202403L P2642R6
__cpp_lib_syncbuf 同期バッファ付き ostream (std::syncbuf, std::osyncstream) とマニピュレータ 201803L (C++20) P0053R7
P0753R2
__cpp_lib_text_encoding std::text_encoding 202306L (C++26) P1885R12
__cpp_lib_three_way_comparison 三方比較 (ライブラリサポート); ライブラリへの三方比較の追加 201907L (C++20) P0768R1
P1614R2
__cpp_lib_to_address ポインタを生ポインタに変換するユーティリティ (std::to_address) 201711L (C++20) P0653R2
__cpp_lib_to_array std::to_array 201907L (C++20) P0325R4
__cpp_lib_to_chars 基本的な文字列変換 (std::to_chars, std::from_chars) 201611L (C++17) P0067R5
P0682R1
LWG3137
<charconv> 関数の成功または失敗のテスト 202306L (C++26) P2497R0
__cpp_lib_to_string std::format を用いた std::to_string の再定義 202306L (C++26) P2587R3
__cpp_lib_to_underlying std::to_underlying 202102L (C++23) P1682R3
__cpp_lib_transformation_trait_aliases 変換特性のためのエイリアステンプレート 201304L (C++14) N3655
__cpp_lib_transparent_operators 透過的な演算子ファンクタ (std::less<> など) 201210L (C++14) N3421
透過的な std::owner_less (std::owner_less<void>) 201510L (C++17) P0074R0
__cpp_lib_trivially_relocatable Trivial な再配置可能性の特性と操作 202502L (C++26) P2786R13
__cpp_lib_tuple_element_t std::tuple_element_t 201402L (C++14) N3887
__cpp_lib_tuple_like std::tuple とタプルライクなオブジェクト (std::pair, std::array, std::subrange) の間の互換性 202207L (C++23) P2165R4
std::complex にタプルプロトコルを追加 202311L (C++26) P2819R2
__cpp_lib_tuples_by_type 型によるタプルのアドレッシング 201304L (C++14) N3670
__cpp_lib_type_identity std::type_identity 201806L (C++20) P0887R1
__cpp_lib_type_trait_variable_templates 型特性変数テンプレート (std::is_void_v, など) 201510L (C++17) P0006R0
__cpp_lib_uncaught_exceptions std::uncaught_exceptions 201411L (C++17) N4259
__cpp_lib_unordered_map_try_emplace std::unordered_map::try_emplace, std::unordered_map::insert_or_assign 201411L (C++17) N4279
__cpp_lib_unreachable std::unreachable 202202L (C++23) P0627R6
__cpp_lib_unwrap_ref std::unwrap_ref_decaystd::unwrap_reference 201811L (C++20) P0318R1
LWG3348
__cpp_lib_variant std::variant: C++17 のための型安全な共用体 201606L (C++17) P0088R3
P0393R3
P0032R3
std::variant から派生したクラスのための std::visit 202102L (C++23)
(DR17)
P2162R2
完全に constexprstd::variant 202106L (C++23)
(DR20)
P2231R1
メンバ visit 202306L (C++26) P2637R3
__cpp_lib_void_t std::void_t 201411L (C++17) N3911
マクロの総数: 255

[編集]

[編集] 通常の使用法

#ifdef __has_include                           // Check if __has_include is present
#  if __has_include(<optional>)                // Check for a standard library
#    include <optional>
#  elif __has_include(<experimental/optional>) // Check for an experimental version
#    include <experimental/optional>
#  elif __has_include(<boost/optional.hpp>)    // Try with an external library
#    include <boost/optional.hpp>
#  else                                        // Not found at all
#     error "Missing <optional>"
#  endif
#endif
 
#ifdef __has_cpp_attribute                      // Check if __has_cpp_attribute is present
#  if __has_cpp_attribute(deprecated)           // Check for an attribute
#    define DEPRECATED(msg) [[deprecated(msg)]]
#  endif
#endif
#ifndef DEPRECATED
#    define DEPRECATED(msg)
#endif
 
DEPRECATED("foo() has been deprecated") void foo();
 
#if __cpp_constexpr >= 201304                // Check for a specific version of a feature
#  define CONSTEXPR constexpr
#else
#  define CONSTEXPR inline
#endif
 
CONSTEXPR int bar(unsigned i)
{
#if __cpp_binary_literals                    // Check for the presence of a feature
    unsigned mask1 = 0b11000000;
    unsigned mask2 = 0b00000111;
#else
    unsigned mask1 = 0xC0;
    unsigned mask2 = 0x07;
#endif
    if (i & mask1)
        return 1;
    if (i & mask2)
        return 2;
    return 0;
}
 
int main() {}

[編集] コンパイラ機能のダンプ

以下の(C++11互換の)プログラムは、C++コンパイラの機能と属性をダンプします。__has_cpp_attribute() の使用は規格に準拠しておらず、gcc/clang の実装に依存することに注意してください。

static constexpr struct change_these_options_to_select_what_will_be_printed
{
    constexpr static int longest_macro_name { 45 };
    constexpr static bool titles               = 1;
    constexpr static bool counters             = 1;
    constexpr static bool attributes           = 1;
    constexpr static bool standard_values      = 1;
    constexpr static bool compiler_specific    = 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 sort_by_date         = 0;
    constexpr static bool separate_year_month  = 1;
    constexpr static bool separated_revisions  = 1;
    constexpr static bool latest_revisions     = 1;
    constexpr static bool cxx98                = 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;
    constexpr static bool cxx26                = 1;
    constexpr static bool cxx29                = 0;
} print;
 
#if __cplusplus < 201100
#  error "C++11 or better is required"
#endif
 
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <utility>
#include <vector>
 
#ifdef __has_include
# if __has_include(<version>)
#   include <version>
# endif
#endif
 
// Expect a string that starts with 6-decimal-digits or with '_' (if unsupported)
#define COMPILER_VALUE_INT(n) #n [0] == '_' ? 0 : \
    (#n[5] - '0') + (#n[4] - '0') * 10 + (#n[3] - '0') * 100 + \
    (#n[2] - '0') * 1000 + (#n[1] - '0') * 10000 + (#n[0] - '0') * 100000
#define COMPILER_FEATURE_ENTRY(expect, name) { #name, COMPILER_VALUE_INT(name), expect },
 
#if defined(__has_cpp_attribute) && defined(__GNUG__)
# define COMPILER_ATTRIBUTE(expect, name) { #name, __has_cpp_attribute(name), expect },
#else
# define COMPILER_ATTRIBUTE(expect, name) { #name, COMPILER_VALUE_INT(name), expect },
#endif
 
#define COMPILER_SPECIFIC_STRING(value) #value
#define COMPILER_SPECIFIC_ENTRY(name) { #name, COMPILER_SPECIFIC_STRING(name) },
 
class CompilerFeature
{
    char const* name_; long data_; long std_;
public:
    constexpr CompilerFeature(char const* name, long data, long std)
        : name_(name), data_(data), std_(std) {}
    constexpr CompilerFeature(CompilerFeature const&) = default;
    CompilerFeature& operator=(CompilerFeature const&) = default;
    bool operator<(CompilerFeature const& rhs) const
        { return std::strcmp(name_, rhs.name_) < 0; }
    bool operator==(CompilerFeature const& rhs) const
        { return std::strcmp(name_, rhs.name_) == 0; }
    constexpr bool supported() const { return data_ >= std_; }
    constexpr bool maybe() const { return data_ > 0; }
    constexpr char const* name() const { return name_; }
    constexpr long std() const { return std_; }
    constexpr long data() const { return data_; }
    void data(long x) { data_ = x; }
};
 
static /*constexpr*/ std::pair<const char*, const char*> compiler[] = {
    COMPILER_SPECIFIC_ENTRY(__cplusplus) //< not compiler specific, but useful :)
    COMPILER_SPECIFIC_ENTRY(__clang_major__)
    COMPILER_SPECIFIC_ENTRY(__clang_minor__)
    COMPILER_SPECIFIC_ENTRY(__clang_patchlevel__)
    COMPILER_SPECIFIC_ENTRY(__GNUG__)
    COMPILER_SPECIFIC_ENTRY(__GNUC_MINOR__)
    COMPILER_SPECIFIC_ENTRY(__GNUC_PATCHLEVEL__)
    // Add your favorite compiler specific macros. Undefined ones will not be printed.
};
 
static constexpr CompilerFeature cxx98_core[] = {
    COMPILER_FEATURE_ENTRY(199711L, __cpp_exceptions)
    COMPILER_FEATURE_ENTRY(199711L, __cpp_rtti)
};
 
static constexpr CompilerFeature cxx11_core[] = {
    COMPILER_FEATURE_ENTRY(200704L, __cpp_alias_templates)
    COMPILER_FEATURE_ENTRY(200809L, __cpp_attributes)
    COMPILER_FEATURE_ENTRY(200704L, __cpp_constexpr)
    COMPILER_FEATURE_ENTRY(201711L, __cpp_constexpr_in_decltype)
    COMPILER_FEATURE_ENTRY(200707L, __cpp_decltype)
    COMPILER_FEATURE_ENTRY(200604L, __cpp_delegating_constructors)
    COMPILER_FEATURE_ENTRY(201511L, __cpp_inheriting_constructors)
    COMPILER_FEATURE_ENTRY(200806L, __cpp_initializer_lists)
    COMPILER_FEATURE_ENTRY(200907L, __cpp_lambdas)
    COMPILER_FEATURE_ENTRY(200809L, __cpp_nsdmi)
    COMPILER_FEATURE_ENTRY(200907L, __cpp_range_based_for)
    COMPILER_FEATURE_ENTRY(200710L, __cpp_raw_strings)
    COMPILER_FEATURE_ENTRY(200710L, __cpp_ref_qualifiers)
    COMPILER_FEATURE_ENTRY(200610L, __cpp_rvalue_references)
    COMPILER_FEATURE_ENTRY(200410L, __cpp_static_assert)
    COMPILER_FEATURE_ENTRY(200806L, __cpp_threadsafe_static_init)
    COMPILER_FEATURE_ENTRY(200704L, __cpp_unicode_characters)
    COMPILER_FEATURE_ENTRY(200710L, __cpp_unicode_literals)
    COMPILER_FEATURE_ENTRY(200809L, __cpp_user_defined_literals)
    COMPILER_FEATURE_ENTRY(200704L, __cpp_variadic_templates)
};
 
static constexpr CompilerFeature cxx14_core[] = {
    COMPILER_FEATURE_ENTRY(201304L, __cpp_aggregate_nsdmi)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_binary_literals)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_constexpr)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_decltype_auto)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_generic_lambdas)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_init_captures)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_return_type_deduction)
    COMPILER_FEATURE_ENTRY(201309L, __cpp_sized_deallocation)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_variable_templates)
};
static constexpr CompilerFeature cxx14_lib[] = {
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_chrono_udls)
    COMPILER_FEATURE_ENTRY(201309L, __cpp_lib_complex_udls)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_exchange_function)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_generic_associative_lookup)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_integer_sequence)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_integral_constant_callable)
    COMPILER_FEATURE_ENTRY(201402L, __cpp_lib_is_final)
    COMPILER_FEATURE_ENTRY(201309L, __cpp_lib_is_null_pointer)
    COMPILER_FEATURE_ENTRY(201402L, __cpp_lib_make_reverse_iterator)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_make_unique)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_null_iterators)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_quoted_string_io)
    COMPILER_FEATURE_ENTRY(201210L, __cpp_lib_result_of_sfinae)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_robust_nonmodifying_seq_ops)
    COMPILER_FEATURE_ENTRY(201402L, __cpp_lib_shared_timed_mutex)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_string_udls)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_transformation_trait_aliases)
    COMPILER_FEATURE_ENTRY(201210L, __cpp_lib_transparent_operators)
    COMPILER_FEATURE_ENTRY(201402L, __cpp_lib_tuple_element_t)
    COMPILER_FEATURE_ENTRY(201304L, __cpp_lib_tuples_by_type)
};
 
static constexpr CompilerFeature cxx17_core[] = {
    COMPILER_FEATURE_ENTRY(201603L, __cpp_aggregate_bases)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_aligned_new)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_capture_star_this)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_constexpr)
    COMPILER_FEATURE_ENTRY(201703L, __cpp_deduction_guides)
    COMPILER_FEATURE_ENTRY(201411L, __cpp_enumerator_attributes)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_fold_expressions)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_guaranteed_copy_elision)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_hex_float)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_if_constexpr)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_inline_variables)
    COMPILER_FEATURE_ENTRY(201411L, __cpp_namespace_attributes)
    COMPILER_FEATURE_ENTRY(201510L, __cpp_noexcept_function_type)
    COMPILER_FEATURE_ENTRY(201411L, __cpp_nontype_template_args)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_nontype_template_parameter_auto)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_range_based_for)
    COMPILER_FEATURE_ENTRY(201411L, __cpp_static_assert)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_structured_bindings)
    COMPILER_FEATURE_ENTRY(201611L, __cpp_template_template_args)
    COMPILER_FEATURE_ENTRY(201611L, __cpp_variadic_using)
};
static constexpr CompilerFeature cxx17_lib[] = {
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_addressof_constexpr)
    COMPILER_FEATURE_ENTRY(201411L, __cpp_lib_allocator_traits_is_always_equal)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_lib_any)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_apply)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_array_constexpr)
    COMPILER_FEATURE_ENTRY(201510L, __cpp_lib_as_const)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_atomic_is_always_lock_free)
    COMPILER_FEATURE_ENTRY(201505L, __cpp_lib_bool_constant)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_boyer_moore_searcher)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_byte)
    COMPILER_FEATURE_ENTRY(201611L, __cpp_lib_chrono)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_clamp)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_enable_shared_from_this)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_execution)
    COMPILER_FEATURE_ENTRY(201703L, __cpp_lib_filesystem)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_lib_gcd_lcm)
    COMPILER_FEATURE_ENTRY(201703L, __cpp_lib_hardware_interference_size)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_lib_has_unique_object_representations)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_hypot)
    COMPILER_FEATURE_ENTRY(201505L, __cpp_lib_incomplete_container_elements)
    COMPILER_FEATURE_ENTRY(201411L, __cpp_lib_invoke)
    COMPILER_FEATURE_ENTRY(201703L, __cpp_lib_is_aggregate)
    COMPILER_FEATURE_ENTRY(201703L, __cpp_lib_is_invocable)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_is_swappable)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_lib_launder)
    COMPILER_FEATURE_ENTRY(201510L, __cpp_lib_logical_traits)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_lib_make_from_tuple)
    COMPILER_FEATURE_ENTRY(201411L, __cpp_lib_map_try_emplace)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_math_special_functions)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_memory_resource)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_lib_node_extract)
    COMPILER_FEATURE_ENTRY(201411L, __cpp_lib_nonmember_container_access)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_not_fn)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_lib_optional)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_parallel_algorithm)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_lib_raw_memory_algorithms)
    COMPILER_FEATURE_ENTRY(201603L, __cpp_lib_sample)
    COMPILER_FEATURE_ENTRY(201703L, __cpp_lib_scoped_lock)
    COMPILER_FEATURE_ENTRY(201505L, __cpp_lib_shared_mutex)
    COMPILER_FEATURE_ENTRY(201611L, __cpp_lib_shared_ptr_arrays)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_lib_shared_ptr_weak_type)
    COMPILER_FEATURE_ENTRY(201606L, __cpp_lib_string_view)
    COMPILER_FEATURE_ENTRY(201611L, __cpp_lib_to_chars)
    COMPILER_FEATURE_ENTRY(201510L, __cpp_lib_transparent_operators)
    COMPILER_FEATURE_ENTRY(201510L, __cpp_lib_type_trait_variable_templates)
    COMPILER_FEATURE_ENTRY(201411L, __cpp_lib_uncaught_exceptions)
    COMPILER_FEATURE_ENTRY(201411L, __cpp_lib_unordered_map_try_emplace)
    COMPILER_FEATURE_ENTRY(202102L, __cpp_lib_variant)
    COMPILER_FEATURE_ENTRY(201411L, __cpp_lib_void_t)
};
 
static constexpr CompilerFeature cxx20_core[] = {
    COMPILER_FEATURE_ENTRY(201902L, __cpp_aggregate_paren_init)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_char8_t)
    COMPILER_FEATURE_ENTRY(202002L, __cpp_concepts)
    COMPILER_FEATURE_ENTRY(201806L, __cpp_conditional_explicit)
    COMPILER_FEATURE_ENTRY(202211L, __cpp_consteval)
    COMPILER_FEATURE_ENTRY(202002L, __cpp_constexpr)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_constexpr_dynamic_alloc)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_constinit)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_deduction_guides)
    COMPILER_FEATURE_ENTRY(201707L, __cpp_designated_initializers)
    COMPILER_FEATURE_ENTRY(201707L, __cpp_generic_lambdas)
    COMPILER_FEATURE_ENTRY(201902L, __cpp_impl_coroutine)
    COMPILER_FEATURE_ENTRY(201806L, __cpp_impl_destroying_delete)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_impl_three_way_comparison)
    COMPILER_FEATURE_ENTRY(201803L, __cpp_init_captures)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_modules)
    COMPILER_FEATURE_ENTRY(201911L, __cpp_nontype_template_args)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_using_enum)
};
static constexpr CompilerFeature cxx20_lib[] = {
    COMPILER_FEATURE_ENTRY(201811L, __cpp_lib_array_constexpr)
    COMPILER_FEATURE_ENTRY(201811L, __cpp_lib_assume_aligned)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_atomic_flag_test)
    COMPILER_FEATURE_ENTRY(201711L, __cpp_lib_atomic_float)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_atomic_lock_free_type_aliases)
    COMPILER_FEATURE_ENTRY(201806L, __cpp_lib_atomic_ref)
    COMPILER_FEATURE_ENTRY(201711L, __cpp_lib_atomic_shared_ptr)
    COMPILER_FEATURE_ENTRY(201911L, __cpp_lib_atomic_value_initialization)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_atomic_wait)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_barrier)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_bind_front)
    COMPILER_FEATURE_ENTRY(201806L, __cpp_lib_bit_cast)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_bitops)
    COMPILER_FEATURE_ENTRY(201902L, __cpp_lib_bounded_array_traits)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_char8_t)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_chrono)
    COMPILER_FEATURE_ENTRY(202002L, __cpp_lib_concepts)
    COMPILER_FEATURE_ENTRY(201806L, __cpp_lib_constexpr_algorithms)
    COMPILER_FEATURE_ENTRY(201711L, __cpp_lib_constexpr_complex)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_constexpr_dynamic_alloc)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_constexpr_functional)
    COMPILER_FEATURE_ENTRY(201811L, __cpp_lib_constexpr_iterator)
    COMPILER_FEATURE_ENTRY(201811L, __cpp_lib_constexpr_memory)
    COMPILER_FEATURE_ENTRY(201911L, __cpp_lib_constexpr_numeric)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_constexpr_string)
    COMPILER_FEATURE_ENTRY(201811L, __cpp_lib_constexpr_string_view)
    COMPILER_FEATURE_ENTRY(201811L, __cpp_lib_constexpr_tuple)
    COMPILER_FEATURE_ENTRY(201811L, __cpp_lib_constexpr_utility)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_constexpr_vector)
    COMPILER_FEATURE_ENTRY(201902L, __cpp_lib_coroutine)
    COMPILER_FEATURE_ENTRY(201806L, __cpp_lib_destroying_delete)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_endian)
    COMPILER_FEATURE_ENTRY(202002L, __cpp_lib_erase_if)
    COMPILER_FEATURE_ENTRY(201902L, __cpp_lib_execution)
    COMPILER_FEATURE_ENTRY(202110L, __cpp_lib_format)
    COMPILER_FEATURE_ENTRY(201811L, __cpp_lib_generic_unordered_lookup)
    COMPILER_FEATURE_ENTRY(202002L, __cpp_lib_int_pow2)
    COMPILER_FEATURE_ENTRY(202002L, __cpp_lib_integer_comparison_functions)
    COMPILER_FEATURE_ENTRY(201902L, __cpp_lib_interpolate)
    COMPILER_FEATURE_ENTRY(201811L, __cpp_lib_is_constant_evaluated)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_is_layout_compatible)
    COMPILER_FEATURE_ENTRY(201806L, __cpp_lib_is_nothrow_convertible)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_is_pointer_interconvertible)
    COMPILER_FEATURE_ENTRY(201911L, __cpp_lib_jthread)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_latch)
    COMPILER_FEATURE_ENTRY(201806L, __cpp_lib_list_remove_return_type)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_math_constants)
    COMPILER_FEATURE_ENTRY(202106L, __cpp_lib_optional)
    COMPILER_FEATURE_ENTRY(201902L, __cpp_lib_polymorphic_allocator)
    COMPILER_FEATURE_ENTRY(202110L, __cpp_lib_ranges)
    COMPILER_FEATURE_ENTRY(201711L, __cpp_lib_remove_cvref)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_semaphore)
    COMPILER_FEATURE_ENTRY(201707L, __cpp_lib_shared_ptr_arrays)
    COMPILER_FEATURE_ENTRY(201806L, __cpp_lib_shift)
    COMPILER_FEATURE_ENTRY(202002L, __cpp_lib_smart_ptr_for_overwrite)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_source_location)
    COMPILER_FEATURE_ENTRY(202002L, __cpp_lib_span)
    COMPILER_FEATURE_ENTRY(201902L, __cpp_lib_ssize)
    COMPILER_FEATURE_ENTRY(201711L, __cpp_lib_starts_ends_with)
    COMPILER_FEATURE_ENTRY(201803L, __cpp_lib_string_view)
    COMPILER_FEATURE_ENTRY(201803L, __cpp_lib_syncbuf)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_three_way_comparison)
    COMPILER_FEATURE_ENTRY(201711L, __cpp_lib_to_address)
    COMPILER_FEATURE_ENTRY(201907L, __cpp_lib_to_array)
    COMPILER_FEATURE_ENTRY(201806L, __cpp_lib_type_identity)
    COMPILER_FEATURE_ENTRY(201811L, __cpp_lib_unwrap_ref)
    COMPILER_FEATURE_ENTRY(202106L, __cpp_lib_variant)
};
 
static constexpr CompilerFeature cxx23_core[] = {
    COMPILER_FEATURE_ENTRY(202110L, __cpp_auto_cast)
    COMPILER_FEATURE_ENTRY(202211L, __cpp_constexpr)
    COMPILER_FEATURE_ENTRY(202110L, __cpp_explicit_this_parameter)
    COMPILER_FEATURE_ENTRY(202106L, __cpp_if_consteval)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_implicit_move)
    COMPILER_FEATURE_ENTRY(202211L, __cpp_multidimensional_subscript)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_named_character_escapes)
    COMPILER_FEATURE_ENTRY(202211L, __cpp_range_based_for)
    COMPILER_FEATURE_ENTRY(202011L, __cpp_size_t_suffix)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_static_call_operator)
};
static constexpr CompilerFeature cxx23_lib[] = {
    COMPILER_FEATURE_ENTRY(202106L, __cpp_lib_adaptor_iterator_pair_constructor)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_algorithm_iterator_requirements)
    COMPILER_FEATURE_ENTRY(202302L, __cpp_lib_allocate_at_least)
    COMPILER_FEATURE_ENTRY(202110L, __cpp_lib_associative_heterogeneous_erasure)
    COMPILER_FEATURE_ENTRY(202302L, __cpp_lib_barrier)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_bind_back)
    COMPILER_FEATURE_ENTRY(202110L, __cpp_lib_byteswap)
    COMPILER_FEATURE_ENTRY(202302L, __cpp_lib_common_reference)
    COMPILER_FEATURE_ENTRY(202302L, __cpp_lib_common_reference_wrapper)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_concepts)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_constexpr_bitset)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_constexpr_charconv)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_constexpr_cmath)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_constexpr_memory)
    COMPILER_FEATURE_ENTRY(202106L, __cpp_lib_constexpr_typeinfo)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_containers_ranges)
    COMPILER_FEATURE_ENTRY(202211L, __cpp_lib_expected)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_flat_map)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_flat_set)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_format)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_format_ranges)
    COMPILER_FEATURE_ENTRY(202302L, __cpp_lib_formatters)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_forward_like)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_generator)
    COMPILER_FEATURE_ENTRY(202106L, __cpp_lib_invoke_r)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_ios_noreplace)
    COMPILER_FEATURE_ENTRY(202302L, __cpp_lib_is_implicit_lifetime)
    COMPILER_FEATURE_ENTRY(202011L, __cpp_lib_is_scoped_enum)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_mdspan)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_modules)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_move_iterator_concept)
    COMPILER_FEATURE_ENTRY(202110L, __cpp_lib_move_only_function)
    COMPILER_FEATURE_ENTRY(202110L, __cpp_lib_optional)
    COMPILER_FEATURE_ENTRY(202106L, __cpp_lib_out_ptr)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_print)
    COMPILER_FEATURE_ENTRY(202302L, __cpp_lib_ranges)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_ranges_as_const)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_ranges_as_rvalue)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_ranges_cartesian_product)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_ranges_chunk)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_ranges_chunk_by)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_ranges_contains)
    COMPILER_FEATURE_ENTRY(202302L, __cpp_lib_ranges_enumerate)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_ranges_find_last)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_ranges_fold)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_ranges_iota)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_ranges_join_with)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_ranges_repeat)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_ranges_slide)
    COMPILER_FEATURE_ENTRY(202106L, __cpp_lib_ranges_starts_ends_with)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_ranges_stride)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_ranges_to_container)
    COMPILER_FEATURE_ENTRY(202110L, __cpp_lib_ranges_zip)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_reference_from_temporary)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_shift)
    COMPILER_FEATURE_ENTRY(202106L, __cpp_lib_spanstream)
    COMPILER_FEATURE_ENTRY(202011L, __cpp_lib_stacktrace)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_start_lifetime_as)
    COMPILER_FEATURE_ENTRY(202011L, __cpp_lib_stdatomic_h)
    COMPILER_FEATURE_ENTRY(202011L, __cpp_lib_string_contains)
    COMPILER_FEATURE_ENTRY(202110L, __cpp_lib_string_resize_and_overwrite)
    COMPILER_FEATURE_ENTRY(202102L, __cpp_lib_to_underlying)
    COMPILER_FEATURE_ENTRY(202207L, __cpp_lib_tuple_like)
    COMPILER_FEATURE_ENTRY(202202L, __cpp_lib_unreachable)
};
 
static constexpr CompilerFeature cxx26_core[] = {
    //< Continue to Populate
    COMPILER_FEATURE_ENTRY(202406L, __cpp_constexpr)
    COMPILER_FEATURE_ENTRY(202411L, __cpp_constexpr_exceptions)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_contracts)
    COMPILER_FEATURE_ENTRY(202403L, __cpp_deleted_function)
    COMPILER_FEATURE_ENTRY(202406L, __cpp_fold_expressions)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_pack_indexing)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_placeholder_variables)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_pp_embed)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_static_assert)
    COMPILER_FEATURE_ENTRY(202411L, __cpp_structured_bindings)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_template_parameters)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_trivial_relocatability)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_trivial_union)
    COMPILER_FEATURE_ENTRY(202403L, __cpp_variadic_friend)
};
static constexpr CompilerFeature cxx26_lib[] = {
    //< Continue to Populate
    COMPILER_FEATURE_ENTRY(202403L, __cpp_lib_algorithm_default_value_type)
    COMPILER_FEATURE_ENTRY(202411L, __cpp_lib_aligned_accessor)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_associative_heterogeneous_insertion)
    COMPILER_FEATURE_ENTRY(202403L, __cpp_lib_atomic_min_max)
    COMPILER_FEATURE_ENTRY(202411L, __cpp_lib_atomic_ref)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_bind_back)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_bind_front)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_bitset)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_chrono)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_constexpr_algorithms)
    COMPILER_FEATURE_ENTRY(202411L, __cpp_lib_constexpr_atomic)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_constexpr_cmath)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_constexpr_complex)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_lib_constexpr_containers)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_lib_constexpr_exceptions)
    COMPILER_FEATURE_ENTRY(202411L, __cpp_lib_constexpr_exceptions)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_lib_constexpr_inplace_vector)
    COMPILER_FEATURE_ENTRY(202406L, __cpp_lib_constexpr_new)
    COMPILER_FEATURE_ENTRY(202411L, __cpp_lib_constrained_equality)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_lib_contracts)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_copyable_function)
    COMPILER_FEATURE_ENTRY(202403L, __cpp_lib_debugging)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_format)
    COMPILER_FEATURE_ENTRY(202403L, __cpp_lib_format_path)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_format_uchar)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_freestanding_algorithm)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_freestanding_array)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_char_traits)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_charconv)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_cstdlib)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_freestanding_cstring)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_cwchar)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_errc)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_freestanding_expected)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_feature_test_macros)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_functional)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_iterator)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_freestanding_mdspan)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_memory)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_freestanding_numeric)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_operator_new)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_freestanding_optional)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_ranges)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_ratio)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_freestanding_string_view)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_tuple)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_freestanding_utility)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_freestanding_variant)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_fstream_native_handle)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_function_ref)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_hazard_pointer)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_lib_hive)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_lib_indirect)
    COMPILER_FEATURE_ENTRY(202406L, __cpp_lib_inplace_vector)
    COMPILER_FEATURE_ENTRY(202411L, __cpp_lib_is_sufficiently_aligned)
    COMPILER_FEATURE_ENTRY(202406L, __cpp_lib_is_virtual_base_of)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_is_within_lifetime)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_linalg)
    COMPILER_FEATURE_ENTRY(202406L, __cpp_lib_mdspan)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_not_fn)
    COMPILER_FEATURE_ENTRY(202406L, __cpp_lib_optional_range_support)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_out_ptr)
    COMPILER_FEATURE_ENTRY(202406L, __cpp_lib_philox_engine)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_lib_polymorphic)
    COMPILER_FEATURE_ENTRY(202403L, __cpp_lib_print)
    COMPILER_FEATURE_ENTRY(202406L, __cpp_lib_ranges)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_ranges_as_const)
    COMPILER_FEATURE_ENTRY(202411L, __cpp_lib_ranges_cache_latest)
    COMPILER_FEATURE_ENTRY(202403L, __cpp_lib_ranges_concat)
    COMPILER_FEATURE_ENTRY(202403L, __cpp_lib_ranges_generate_random)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_lib_ranges_reserve_hint)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_lib_ranges_to_input)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_ratio)
    COMPILER_FEATURE_ENTRY(202411L, __cpp_lib_raw_memory_algorithms)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_rcu)
    COMPILER_FEATURE_ENTRY(202403L, __cpp_lib_reference_wrapper)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_saturation_arithmetic)
    COMPILER_FEATURE_ENTRY(202406L, __cpp_lib_senders)
    COMPILER_FEATURE_ENTRY(202411L, __cpp_lib_simd)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_smart_ptr_owner_equality)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_span)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_span_initializer_list)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_sstream_from_string_view)
    COMPILER_FEATURE_ENTRY(202403L, __cpp_lib_string_view)
    COMPILER_FEATURE_ENTRY(202403L, __cpp_lib_submdspan)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_text_encoding)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_to_chars)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_to_string)
    COMPILER_FEATURE_ENTRY(202502L, __cpp_lib_trivially_relocatable)
    COMPILER_FEATURE_ENTRY(202311L, __cpp_lib_tuple_like)
    COMPILER_FEATURE_ENTRY(202306L, __cpp_lib_variant)
};
 
static constexpr CompilerFeature cxx29_core[] = {
    //< Continue to Populate
    COMPILER_FEATURE_ENTRY(202604L, __cpp_core_TODO)
};
static constexpr CompilerFeature cxx29_lib[] = {
    //< Continue to Populate
    COMPILER_FEATURE_ENTRY(202604L, __cpp_lib_TODO)
};
 
static constexpr CompilerFeature attributes[] = {
    COMPILER_ATTRIBUTE(202207L, assume)
    COMPILER_ATTRIBUTE(200809L, carries_dependency)
    COMPILER_ATTRIBUTE(201309L, deprecated)
    COMPILER_ATTRIBUTE(201603L, fallthrough)
    COMPILER_ATTRIBUTE(202403L, indeterminate)
    COMPILER_ATTRIBUTE(201803L, likely)
    COMPILER_ATTRIBUTE(201603L, maybe_unused)
    COMPILER_ATTRIBUTE(201803L, no_unique_address)
    COMPILER_ATTRIBUTE(201907L, nodiscard)
    COMPILER_ATTRIBUTE(200809L, noreturn)
    COMPILER_ATTRIBUTE(201803L, unlikely)
};
 
inline void show_compiler_specific_info()
{
    std::printf("Compiler specific macros:\n");
    for (auto co : compiler)
        if (std::strcmp(co.first, co.second))
            std::printf("%*s %s\n", -print.longest_macro_name, co.first, co.second);
}
 
inline void print_compiler_feature(const CompilerFeature& x)
{
    if (not ((print.supported_features and x.maybe()) or
            (print.unsupported_features and not x.maybe())))
        return;
    auto print_year_month = [](long n)
    {
        return std::printf("%ld%s%02ld",
            n / 100, print.separate_year_month ? "-" : "", n % 100);
    };
    std::printf("%*s ", -print.longest_macro_name, x.name());
    x.maybe() ? print_year_month(x.data()) :
                    std::printf("------%s", print.separate_year_month ? "-" : "");
    if (print.standard_values)
        std::printf("  %c  ", (x.supported() ? (x.data() > x.std() ? '>' : '=') : '<')),
            print_year_month(x.std());
    std::puts("");
}
 
template<class Container>
inline void show(char const* const title, Container const& co)
{
    if (print.titles)
    {
        std::printf("%-s (", title);
        if (print.counters)
        {
            std::printf("%zd/", std::count_if(std::begin(co), std::end(co),
                [](CompilerFeature x)
                {
                    return x.supported();
                }));
        }
        std::printf("%td)\n", std::distance(std::begin(co), std::end(co)));
    }
    if (print.sort_by_date)
    {
        std::vector<CompilerFeature> v(std::begin(co), std::end(co));
        std::stable_sort(v.begin(), v.end(),
            [](CompilerFeature const& lhs, CompilerFeature const& rhs)
            {
                return lhs.data() < rhs.data();
            });
        std::for_each(v.cbegin(), v.cend(), print_compiler_feature);
    }
    else
        std::for_each(std::begin(co), std::end(co), print_compiler_feature);
    std::puts("");
}
 
inline void show_latest()
{
    auto latest_rev = []() -> int
    {
        return print.cxx29 ? 29 : print.cxx26 ? 26 : print.cxx23 ? 23 : print.cxx20 ? 20 :
               print.cxx17 ? 17 : print.cxx14 ? 14 : print.cxx11 ? 11 : 98;
    };
    std::vector<CompilerFeature> latest;
    auto add = [&latest](CompilerFeature x)
    {
        auto i = std::lower_bound(latest.begin(), latest.end(), x);
        if (i == latest.end() or not (*i == x))
            latest.insert(i, x);
        else if (i->data() < x.data())
            i->data(x.data());
    };
    char text[64];
    latest.reserve(512); // max macros
    if (print.core_features)
    {   // preserve reverse revision insertion order!
        if (print.cxx29) std::for_each(std::begin(cxx29_core), std::end(cxx29_core), add);
        if (print.cxx26) std::for_each(std::begin(cxx26_core), std::end(cxx26_core), add);
        if (print.cxx23) std::for_each(std::begin(cxx23_core), std::end(cxx23_core), add);
        if (print.cxx20) std::for_each(std::begin(cxx20_core), std::end(cxx20_core), add);
        if (print.cxx17) std::for_each(std::begin(cxx17_core), std::end(cxx17_core), add);
        if (print.cxx14) std::for_each(std::begin(cxx14_core), std::end(cxx14_core), add);
        if (print.cxx11) std::for_each(std::begin(cxx11_core), std::end(cxx11_core), add);
        if (print.cxx98) std::for_each(std::begin(cxx98_core), std::end(cxx98_core), add);
        std::snprintf(text, sizeof text, "ALL CORE MACROS UP TO C++%02i", latest_rev());
        show(text, latest);
    }
    latest.clear();
    if (print.lib_features)
    {   // preserve reverse revision insertion order!
        if (print.cxx29) std::for_each(std::begin(cxx29_lib), std::end(cxx29_lib), add);
        if (print.cxx26) std::for_each(std::begin(cxx26_lib), std::end(cxx26_lib), add);
        if (print.cxx23) std::for_each(std::begin(cxx23_lib), std::end(cxx23_lib), add);
        if (print.cxx20) std::for_each(std::begin(cxx20_lib), std::end(cxx20_lib), add);
        if (print.cxx17) std::for_each(std::begin(cxx17_lib), std::end(cxx17_lib), add);
        if (print.cxx14) std::for_each(std::begin(cxx14_lib), std::end(cxx14_lib), add);
        std::snprintf(text, sizeof text, "ALL LIB MACROS UP TO C++%02i", latest_rev());
        show(text, latest);
    }
}
 
int main()
{
    if (print.separated_revisions)
    {
        if (print.cxx98 and print.core_features) show("C++98 CORE", cxx98_core);
        if (print.cxx11 and print.core_features) show("C++11 CORE", cxx11_core);
        if (print.cxx14 and print.core_features) show("C++14 CORE", cxx14_core);
        if (print.cxx14 and print.lib_features ) show("C++14 LIB" , cxx14_lib);
        if (print.cxx17 and print.core_features) show("C++17 CORE", cxx17_core);
        if (print.cxx17 and print.lib_features ) show("C++17 LIB" , cxx17_lib);
        if (print.cxx20 and print.core_features) show("C++20 CORE", cxx20_core);
        if (print.cxx20 and print.lib_features ) show("C++20 LIB" , cxx20_lib);
        if (print.cxx23 and print.core_features) show("C++23 CORE", cxx23_core);
        if (print.cxx23 and print.lib_features ) show("C++23 LIB" , cxx23_lib);
        if (print.cxx26 and print.core_features) show("C++26 CORE", cxx26_core);
        if (print.cxx26 and print.lib_features ) show("C++26 LIB" , cxx26_lib);
        if (print.cxx29 and print.core_features) show("C++29 CORE", cxx29_core);
        if (print.cxx29 and print.lib_features ) show("C++29 LIB" , cxx29_lib);
    }
    if (print.latest_revisions) show_latest();
    if (print.attributes) show("ATTRIBUTES", attributes);
    if (print.compiler_specific) show_compiler_specific_info();
}

実行結果の例

C++11 CORE (20/20)
__cpp_alias_templates                         2007-04  =  2007-04
__cpp_attributes                              2008-09  =  2008-09
__cpp_constexpr                               2022-11  >  2007-04
__cpp_constexpr_in_decltype                   2017-11  =  2017-11
... truncated ...
 
C++14 CORE (9/9)
__cpp_aggregate_nsdmi                         2013-04  =  2013-04
__cpp_binary_literals                         2013-04  =  2013-04
__cpp_constexpr                               2022-11  >  2013-04
... truncated ...
 
C++14 LIB (20/20)
__cpp_lib_chrono_udls                         2013-04  =  2013-04
__cpp_lib_complex_udls                        2013-09  =  2013-09
__cpp_lib_exchange_function                   2013-04  =  2013-04
... truncated ...
 
... truncated ...
 
C++23 LIB (43/64)
__cpp_lib_adaptor_iterator_pair_constructor   2021-06  =  2021-06
__cpp_lib_algorithm_iterator_requirements     -------  <  2022-07
__cpp_lib_allocate_at_least                   -------  <  2023-02
__cpp_lib_associative_heterogeneous_erasure   -------  <  2021-10
__cpp_lib_barrier                             2019-07  <  2023-02
... truncated ...
 
ALL CORE MACROS UP TO C++26 (60/76)
__cpp_aggregate_bases                         2016-03  =  2016-03
__cpp_aggregate_nsdmi                         2013-04  =  2013-04
__cpp_aggregate_paren_init                    2019-02  =  2019-02
__cpp_alias_templates                         2007-04  =  2007-04
... truncated ...
 
ALL LIB MACROS UP TO C++26 (158/255)
__cpp_lib_adaptor_iterator_pair_constructor   2021-06  =  2021-06
__cpp_lib_addressof_constexpr                 2016-03  =  2016-03
__cpp_lib_algorithm_iterator_requirements     -------  <  2022-07
__cpp_lib_allocate_at_least                   -------  <  2023-02
__cpp_lib_allocator_traits_is_always_equal    2014-11  =  2014-11
... truncated ...
 
ATTRIBUTES (9/11)
assume                                        2022-07  =  2022-07
carries_dependency                            -------  <  2008-09
deprecated                                    2013-09  =  2013-09
fallthrough                                   2016-03  =  2016-03
... truncated ...
 
Compiler specific macros:
__cplusplus                                   202302L
__GNUG__                                      14
__GNUC_MINOR__                                2
__GNUC_PATCHLEVEL__                           0

[編集] 欠陥報告

以下の動作変更を伴う欠陥報告が、以前に公開されたC++標準に遡って適用されました。

DR 適用対象 公開された動作 正しい動作
P2552R3 C++20 __has_cpp_attribute は標準属性に対してゼロ以外の値に展開されなければならない 0 に展開されうる

[編集] 関連項目

ライブラリ機能テストマクロ (C++20) ヘッダ <version> で定義されている
事前定義マクロシンボル
マクロシンボルインデックス

[編集] 外部リンク

1.  機能テストの推奨事項に関する公式文書
2.  コンパイラ機能をダンプするためのソースコード
English 日本語 中文(简体) 中文(繁體)