最終更新日時(UTC):
が更新

履歴 編集

機能テストマクロ(C++26)

このページはC++26に採用された言語機能の変更を解説しています。

のちのC++規格でさらに変更される場合があるため関連項目を参照してください。

概要

言語機能

マクロ名 機能
__cpp_constexpr 202406L 定数式でのvoid*からポインタ型へのキャストを許可
constexpr配置new
__cpp_constexpr_exceptions 202411L 定数評価での例外送出を許可
__cpp_constexpr_virtual_inheritance 202506L constexpr仮想継承を許可
__cpp_contracts 202502L 契約プログラミングをサポートする
__cpp_deleted_function 202403L 関数宣言を削除する理由を指定できるようにする
__cpp_expansion_statements 202506L コンパイル時のタプルやリストを展開処理するtemplate for
__cpp_impl_reflection 202506L 静的リフレクション
__cpp_pack_indexing 202311L パラメータパックへのインデックスアクセスを許可
__cpp_placeholder_variables 202306L 宣言のみで使用しない変数の名前として_をサポート
__cpp_pp_embed 202502L ファイルを読み込む#embed命令を追加
__cpp_static_assert 202306L static_assertの診断メッセージにユーザーが生成した文字列の指定を許可
__cpp_structured_bindings 202411L 構造化束縛への属性を許可
構造化束縛でパックを導入できるようにする
__cpp_template_parameters 202502L コンセプトと変数テンプレートにテンプレートテンプレートパラメータのサポートを追加
__cpp_trivial_relocatability 202502L トリビアルな再配置
__cpp_trivial_union 202502L 共用体をトリビアルに未初期化できるようにする
__cpp_variadic_friend 202403L 可変引数テンプレートでfriend宣言をできるようにする

ライブラリ

ライブラリの機能テストマクロは全て<version>でも提供される。

マクロ名 機能 ヘッダ
__cpp_lib_algorithm_default_value_type 202403L 一部アルゴリズムに、値を波カッコ初期化で渡せるよう制約を追加 <algorithm>, <ranges>, <string>, <deque>, <list>, <forward_list>, <vector>
__cpp_lib_aligned_accessor 202411L <mdspan>に、要素アクセスにアライメント保証を与えるstd::aligned_accessorを追加 <mdspan>
__cpp_lib_associative_heterogeneous_insertion 202306L 連想コンテナの一部メンバ関数に、一時オブジェクト生成のコストを抑える拡張を追加 <map>, <set>, <unordered_map>, <unordered_set>
__cpp_lib_apply 202506L std::apply戻り値型推論をやめて、戻り値型用のstd::apply_resultクラスを追加 <tuple>, <type_traits>
__cpp_lib_atomic_min_max 202506L std::atomicオブジェクトに対する2つの値の最大値・最小値を取得する関数を追加 <atomic>
__cpp_lib_atomic_reductions 202506L std::atomicstd::atomic_refに高速な縮約用の操作を追加 <atomic>
__cpp_lib_atomic_ref 202411L std::atomic_refaddress()メンバ関数を追加 <atomic>
__cpp_lib_bind_back 202306L std::bind_back()に、非型テンプレート引数として関数を指定するオーバーロードを追加 <functional>
__cpp_lib_bind_front 202306L std::bind_front()に、非型テンプレート引数として関数を指定するオーバーロードを追加 <functional>
__cpp_lib_bitset 202306L std::bitsetに、std::basic_string_viewを受け取るコンストラクタを追加 <bitset>
__cpp_lib_chrono 202306L <chrono>のクラスに、ハッシュ値サポートとしてstd::hashの特殊化を追加 <chrono>
__cpp_lib_constant_wrapper 202506L <type_traits>std::constant_wrapperを追加 <type_traits>
__cpp_lib_constexpr_algorithms 202306L std::stable_sort() / std::ranges::stable_sort()constexpr対応 <algorithm>, <utility>
__cpp_lib_constexpr_atomic 202411L <atomic>ライブラリのアトミック操作をconstexpr対応 <atomic>
__cpp_lib_constexpr_cmath 202306L <cmath>の関数 (特殊関数と丸めモードに依存する関数以外の全て) をconstexpr対応 <cmath>, <cstdlib>
__cpp_lib_constexpr_complex 202306L std::complexの全関数をconstexpr対応 <complex>
__cpp_lib_constexpr_deque 202502L std::dequeconstexpr対応 <deque>
__cpp_lib_constexpr_exceptions 202502L 定数式での例外送出が許可されることにともない、例外クラスの関連機能をconstexpr対応 <exception>, <stdexcept>, <expected>, <optional>, <variant>, <format>
__cpp_lib_constexpr_flat_map 202502L std::flat_map / std::flat_multimapconstexpr対応 <flat_map>
__cpp_lib_constexpr_flat_set 202502L std::flat_set / std::flat_multisetconstexpr対応 <flat_set>
__cpp_lib_constexpr_forward_list 202502L std::forward_listconstexpr対応 <forward_list>
__cpp_lib_constexpr_inplace_vector 202502L std::inplace_vectorconstexpr対応 <inplace_vector>
__cpp_lib_constexpr_list 202502L std::listconstexpr対応 <list>
__cpp_lib_constexpr_map 202502L std::map / std::multimapconstexpr対応 <map>
__cpp_lib_constexpr_memory 202506L std::shared_ptrクラスとその関連機能をconstexpr対応 <memory>
__cpp_lib_constexpr_new 202406L constexpr配置new <new>
__cpp_lib_constexpr_queue 202502L std::queue / std::priority_queueconstexpr対応 <queue>
__cpp_lib_constexpr_set 202502L std::set / std::multisetconstexpr対応 <set>
__cpp_lib_constexpr_stack 202502L std::stackconstexpr対応 <stack>
__cpp_lib_constexpr_unordered_map 202502L std::unordered_map / std::unordered_multimapconstexpr対応 <unordered_map>
__cpp_lib_constexpr_unordered_set 202502L std::unordered_set / std::unordered_multisetconstexpr対応 <unordered_set>
__cpp_lib_constrained_equality 202411L std::reference_wrapperに、比較演算子==<=>を追加 <utility>, <tuple>, <optional>, <variant>, <expected>
__cpp_lib_contracts 202502L 契約プログラミングをサポートする <contracts>
__cpp_lib_copyable_function 202306L <functional>std::copyable_functionを追加 <functional>
__cpp_lib_counting_scope 202506L <execution>std::execution::spawnstd::execution::scope_tokenなどを追加 <execution>
__cpp_lib_debugging 202403L デバッグサポートのライブラリとして<debugging>を追加 <debugging>
__cpp_lib_define_static 202506L <meta>
__cpp_lib_exception_ptr_cast 202506L std::exception_ptrを指定した例外型にキャストするstd::exception_ptr_cast()関数を追加 <exception>
__cpp_lib_format 202311L <format>
__cpp_lib_format_path 202506L std::filesystem::pathクラスに、文字列フォーマットのサポートを追加
std::filesystem::pathクラスに、出力用の文字列を取得するためのメンバ関数を追加
<filesystem>
__cpp_lib_format_uchar 202311L std::formatcharを数値出力する際は符号なしとして扱う <format>
__cpp_lib_freestanding_algorithm 202502L <algorithm>
__cpp_lib_freestanding_array 202311L <array>
__cpp_lib_freestanding_char_traits 202306L <string>
__cpp_lib_freestanding_charconv 202306L <charconv>
__cpp_lib_freestanding_cstdlib 202306L <cstdlib>, <cmath>
__cpp_lib_freestanding_cstring 202311L <cstring>
__cpp_lib_freestanding_cwchar 202306L <cwchar>
__cpp_lib_freestanding_errc 202306L <cerrno>, <system_error>
__cpp_lib_freestanding_execution 202502L <execution>
__cpp_lib_freestanding_expected 202311L <expected>
__cpp_lib_freestanding_feature_test_macros 202306L
__cpp_lib_freestanding_functional 202306L <functional>
__cpp_lib_freestanding_iterator 202306L <iterator>
__cpp_lib_freestanding_mdspan 202311L <mdspan>
__cpp_lib_freestanding_memory 202502L <memory>
__cpp_lib_freestanding_numeric 202502L <numeric>
__cpp_lib_freestanding_operator_new 202306L or 0 <new>
__cpp_lib_freestanding_optional 202506L <optional>
__cpp_lib_freestanding_random 202502L <random>
__cpp_lib_freestanding_ranges 202306L <ranges>
__cpp_lib_freestanding_ratio 202306L <ratio>
__cpp_lib_freestanding_string_view 202311L <string_view>
__cpp_lib_freestanding_tuple 202306L <tuple>
__cpp_lib_freestanding_utility 202306L <utility>
__cpp_lib_freestanding_variant 202311L <variant>
__cpp_lib_fstream_native_handle 202306L std::basic_fstreamなどのメンバに、ファイルのネイティブハンドルを追加 <fstream>
__cpp_lib_function_ref 202306L <functional>std::function_refを追加 <functional>
__cpp_lib_hazard_pointer 202306L ハザードポインタのライブラリ<hazard_pointer>を追加 <hazard_pointer>
__cpp_lib_hive 202502L シーケンスコンテナのライブラリ<hive>を追加 <hive>
__cpp_lib_indirect 202502L <memory>std::indirectstd::polymorphicを追加 <memory>
__cpp_lib_inplace_vector 202406L 容量固定の可変長配列のライブラリ<inplace_vector>を追加 <inplace_vector>
__cpp_lib_is_sufficiently_aligned 202411L <mdspan>に、要素アクセスにアライメント保証を与えるstd::aligned_accessorを追加 <memory>
__cpp_lib_is_virtual_base_of 202406L <type_traits>std::is_virtual_base_ofを追加 <type_traits>
__cpp_lib_is_within_lifetime 202306L <type_traits>std::is_within_lifetime()を追加 <type_traits>
__cpp_lib_linalg 202412L 線形代数ライブラリとして<linalg>を追加 <linalg>
__cpp_lib_mdspan 202406L std::mdspanに対するstd::dextents指定の冗長さを解決するstd::dimsを追加 <mdspan>
__cpp_lib_not_fn 202306L std::not_fn()に、非型テンプレート引数として関数を指定するオーバーロードを追加 <functional>
__cpp_lib_observable_checkpoint 202506L <utility>std::observable_checkpoint()を追加 <utility>
__cpp_lib_optional 202506L std::optionalに、参照を保持するためのT&の部分特殊化を追加 <optional>
__cpp_lib_optional_range_support 202406L std::optionalにイテレータインタフェースを追加 <optional>
__cpp_lib_out_ptr 202311L <memory>
__cpp_lib_parallel_algorithm 202506L <algorithm><memory>のアルゴリズムを並列実行に対応 <algorithm>, <numeric>, <memory>
__cpp_lib_parallel_scheduler 202506L <execution>std::execution::parallel_schedulerを追加 <execution>
__cpp_lib_philox_engine 202406L <random>std::philox_enginestd::philox4x32std::philox4x64を追加 <random>
__cpp_lib_polymorphic 202502L <memory>std::indirectstd::polymorphicを追加 <memory>
__cpp_lib_print 202406L std::print()std::println()にロックを取得せず高速に書き出す最適化を許可
std::enable_nonlocking_formatter_optimizationを追加
<print>, <ostream>
__cpp_lib_ranges 202406L std::indirectly_unary_invocableなどのコンセプトの共通参照要件を削除 <algorithm>, <functional>, <iterator>, <memory>, <ranges>
__cpp_lib_ranges_as_const 202311L std::basic_const_iteratorを元の要素へのキャストを可能にする <ranges>
__cpp_lib_ranges_cache_latest 202411L std::views::cache_latestを追加 <ranges>
__cpp_lib_ranges_concat 202403L std::views::concatを追加 <ranges>
__cpp_lib_ranges_generate_random 202403L <random>に、乱数列を生成するstd::ranges::generate_random()関数を追加 <random>
__cpp_lib_ranges_indices 202506L インデックス列を生成するstd::views::indicesを追加 <ranges>
__cpp_lib_ranges_reserve_hint 202502L 各viewクラスにreserve_hint()メンバ関数を追加
std::ranges::reserve_hint()関数を追加
std::ranges::approximately_sized_rangeコンセプトを追加
<ranges>
__cpp_lib_ranges_to_input 202502L std::views::to_inputを追加 <ranges>
__cpp_lib_ratio 202306L <ratio>に、新たなSI接頭辞を追加 <ratio>
__cpp_lib_raw_memory_algorithms 202411L std::uninitialized_default_construct()などの未初期化領域に対する操作をconstexpr対応 <memory>
__cpp_lib_rcu 202306L RCU (Read Copy Update) のライブラリとして<rcu>を追加 <rcu>
__cpp_lib_reference_wrapper 202403L std::reference_wrapperに、比較演算子==<=>を追加 <functional>
__cpp_lib_reflection 202506L <meta>
__cpp_lib_saturation_arithmetic 202311L <numeric>に飽和演算 (Saturation Arithmetic) としてstd::add_sat()などの関数を追加 <numeric>
__cpp_lib_senders 202506L <execution>
__cpp_lib_simd 202506L データ並列ライブラリとして、<simd>を追加 <simd>
__cpp_lib_simd_complex 202502L <simd>std::complexをサポートする <simd>
__cpp_lib_simd_permutations 202506L <simd>permute()などを追加する <simd>
__cpp_lib_smart_ptr_owner_equality 202306L <memory>std::owner_hashstd::owner_equalを追加 <memory>
__cpp_lib_span 202311L std::mdspanat()メンバ関数を追加 <span>
__cpp_lib_span_initializer_list 202311L std::spanstd::initializer_listをとるコンストラクタを追加 <span>
__cpp_lib_sstream_from_string_view 202306L std::basic_stringstreamなどがstd::basic_string_viewから構築可能に <sstream>
__cpp_lib_string_subview 202506L std::basic_stringstd::basic_string_viewsubview()を追加 <string>, <string_view>
__cpp_lib_string_view 202403L std::basic_stringstd::basic_string_viewを連結させるoperator+を追加 <string>, <string_view>
__cpp_lib_submdspan 202411L std::mdspanから部分ビューを取り出すstd::submdspan()を追加 <mdspan>
__cpp_lib_task 202506L <execution>
__cpp_lib_text_encoding 202306L 文字列エンコーディングを識別するライブラリ<text_encoding>を追加 <text_encoding>
__cpp_lib_to_chars 202306L std::to_chars_resultstd::from_chars_resultoperator boolを追加 <charconv>
__cpp_lib_to_string 202306L std::to_stringの変換結果をsprintf()ベースからstd::format()ベースに変更 <string>
__cpp_lib_trivially_relocatable 202502L トリビアルな再配置 <memory>, <type_traits>
__cpp_lib_tuple_like 202311L std::complexにタプルインタフェースの特殊化を追加 <utility>, <tuple>, <map>, <unordered_map>
__cpp_lib_type_order 202506L std::type_info::beforeのconstexpr化 <compare>
__cpp_lib_variant 202306L std::variantクラスに、メンバ関数版のvisit()を追加 <variant>

実装依存のマクロ。

マクロ名 機能 ヘッダ
__cpp_lib_hardened_array 202502L <array>
__cpp_lib_hardened_basic_stacktrace 202506L <stacktrace>
__cpp_lib_hardened_basic_string 202502L <string>
__cpp_lib_hardened_basic_string_view 202502L <string_view>
__cpp_lib_hardened_bitset 202502L <bitset>
__cpp_lib_hardened_common_iterator 202506L <iterator>
__cpp_lib_hardened_counted_iterator 202506L <iterator>
__cpp_lib_hardened_deque 202502L <deque>
__cpp_lib_hardened_expected 202502L <expected>
__cpp_lib_hardened_forward_list 202502L <forward_list>
__cpp_lib_hardened_inplace_vector 202502L <inplace_vector>
__cpp_lib_hardened_list 202502L <list>
__cpp_lib_hardened_mdspan 202502L <mdspan>
__cpp_lib_hardened_optional 202502L <optional>
__cpp_lib_hardened_shared_ptr_array 202506L <memory>
__cpp_lib_hardened_span 202502L <span>
__cpp_lib_hardened_valarray 202502L <valarray>
__cpp_lib_hardened_vector 202502L <vector>
__cpp_lib_hardened_view_interface 202506L <ranges>

参照