標準ライブラリヘッダ <type_traits>
提供: cppreference.com
このヘッダは型サポートライブラリの一部です。
クラス | ||
ヘルパークラス | ||
(C++11)(C++17) | 指定された値を持つ指定された型のコンパイル時定数 (クラステンプレート) | |
true_type | std::integral_constant<bool, true> | |
false_type | std::integral_constant<bool, false> | |
一次型カテゴリ | ||
(C++11) | 型が void かどうか調べます (クラステンプレート) | |
(C++14) | 型が std::nullptr_t かどうか調べます (クラステンプレート) | |
(C++11) | 型が整数型かどうか調べます (クラステンプレート) | |
(C++11) | 型が浮動小数点型かどうか調べます (クラステンプレート) | |
(C++11) | 型が配列型かどうか調べます (クラステンプレート) | |
(C++11) | 型が列挙型かどうか調べます (クラステンプレート) | |
(C++11) | 型が共用体型かどうか調べます (クラステンプレート) | |
(C++11) | 型がクラス型 (共用体を除く) かどうか調べます (クラステンプレート) | |
(C++11) | 型が関数型かどうか調べます (クラステンプレート) | |
(C++11) | 型がポインタ型かどうか調べます (クラステンプレート) | |
(C++11) | 型が左辺値参照かどうか調べます (クラステンプレート) | |
(C++11) | 型が右辺値参照かどうか調べます (クラステンプレート) | |
(C++11) | 型が非静的メンバオブジェクトへのポインタかどうか調べます (クラステンプレート) | |
(C++11) | 型が非静的メンバ関数へのポインタかどうか調べます (クラステンプレート) | |
複合型カテゴリ | ||
(C++11) | 型が基本型かどうか調べます (クラステンプレート) | |
(C++11) | 型が算術型かどうか調べます (クラステンプレート) | |
(C++11) | 型がスカラー型かどうか調べます (クラステンプレート) | |
(C++11) | 型がオブジェクト型かどうか調べます (クラステンプレート) | |
(C++11) | 型が複合型かどうか調べます (クラステンプレート) | |
(C++11) | 型が左辺値参照または右辺値参照かどうか調べます (クラステンプレート) | |
(C++11) | 型が非静的メンバ関数または非静的メンバオブジェクトかどうか調べます (クラステンプレート) | |
型の性質 | ||
(C++11) | 型が const 修飾されているかどうか調べます (クラステンプレート) | |
(C++11) | 型が volatile 修飾されているかどうか調べます (クラステンプレート) | |
(C++11) | 型がトリビアルかどうか調べます (クラステンプレート) | |
(C++11) | 型がトリビアルにコピー可能かどうか調べます (クラステンプレート) | |
(C++11) | 型が標準レイアウト型かどうか調べます (クラステンプレート) | |
(C++11)(C++20で非推奨) | 型が POD (plain-old data) 型かどうか調べます (クラステンプレート) | |
(C++11)(C++17で非推奨)(C++20で削除) | 型がリテラル型かどうか調べます (クラステンプレート) | |
型のオブジェクト表現のすべてのビットが値に寄与するかどうか調べます (クラステンプレート) | ||
(C++11) | 型がクラス型 (共用体を除く) かつ非静的データメンバを持たないかどうか調べます (クラステンプレート) | |
(C++11) | 型が多相クラス型かどうか調べます (クラステンプレート) | |
(C++11) | 型が抽象クラス型かどうか調べます (クラステンプレート) | |
(C++14) | 型が final クラス型かどうか調べます (クラステンプレート) | |
(C++17) | 型が集成体型かどうか調べます (クラステンプレート) | |
(C++11) | 型が符号付き算術型かどうか調べます (クラステンプレート) | |
(C++11) | 型が符号なし算術型かどうか調べます (クラステンプレート) | |
(C++20) | 型が境界の既知な配列型かどうか調べます (クラステンプレート) | |
(C++20) | 型が境界の未知な配列型かどうか調べます (クラステンプレート) |
サポートされている操作 | |
(C++11)(C++11)(C++11) | 型が特定の引数に対するコンストラクタを持っているかどうか調べます (クラステンプレート) |
型がデフォルトコンストラクタを持っているかどうか調べます (クラステンプレート) | |
(C++11)(C++11)(C++11) | 型がコピーコンストラクタを持っているかどうか調べます (クラステンプレート) |
(C++11)(C++11)(C++11) | 型が右辺値参照から構築できるかどうか調べます (クラステンプレート) |
(C++11)(C++11)(C++11) | 型が特定の引数に対する代入演算子を持っているかどうか調べます (クラステンプレート) |
(C++11)(C++11)(C++11) | 型がコピー代入演算子を持っているかどうか調べます (クラステンプレート) |
(C++11)(C++11)(C++11) | 型がムーブ代入演算子を持っているかどうか調べます (クラステンプレート) |
(C++11)(C++11)(C++11) | 型が削除されていないデストラクタを持っているかどうか調べます (クラステンプレート) |
(C++11) | 型が仮想デストラクタを持っているかどうか調べます (クラステンプレート) |
(C++17)(C++17)(C++17)(C++17) | その型のオブジェクトが同じ型または何らかの別の型のオブジェクトと swap 可能かどうか調べます (クラステンプレート) |
性質の問い合わせ | |
(C++11) | 型のアライメント要件を取得します (クラステンプレート) |
(C++11) | 配列型の次元数を取得します (クラステンプレート) |
(C++11) | 配列型の指定された次元のサイズを取得します (クラステンプレート) |
型の関係 | |
(C++11) | 2つの型が同じかどうか調べます (クラステンプレート) |
(C++11) | 型が別の型から派生しているかどうか調べます (クラステンプレート) |
(C++11)(C++20) | 型が別の型に変換可能かどうか調べます (クラステンプレート) |
(C++20) | 2つの型がレイアウト互換かどうか調べます (クラステンプレート) |
ある型が別の型のポインタ相互変換可能な (最初の) 基底かどうか調べます (クラステンプレート) | |
型が指定された引数型で (std::invoke によるかのように) 呼ぶことが可能かどうか調べます (クラステンプレート) | |
const volatile 指定子 | |
(C++11)(C++11)(C++11) | 指定された型から const, volatile またはその両方の指定子を削除します (クラステンプレート) |
(C++11)(C++11)(C++11) | 指定された型に const, volatile またはその両方の指定子を追加します (クラステンプレート) |
参照 | |
(C++11) | 指定された型から参照を削除します (クラステンプレート) |
(C++11)(C++11) | 指定された型に左辺値参照または右辺値参照を追加します (クラステンプレート) |
ポインタ | |
(C++11) | 指定された型からポインタを削除します (クラステンプレート) |
(C++11) | 指定された型にポインタを追加します (クラステンプレート) |
符号変更 | |
(C++11) | 指定された整数型を符号付きにします (クラステンプレート) |
(C++11) | 指定された整数型を符号なしにします (クラステンプレート) |
配列 | |
(C++11) | 指定された配列型からエクステントを1つ削除します (クラステンプレート) |
(C++11) | 指定された配列型からすべてのエクステントを削除します (クラステンプレート) |
その他の変換 | |
(C++11) | 指定されたサイズの未初期化記憶域として使用するのに適した型を定義します (クラステンプレート) |
(C++11) | 指定された型すべてのための未初期化記憶域として使用するのに適した型を定義します (クラステンプレート) |
(C++11) | 関数に引数を値渡ししたときと同様の型変換を適用します (クラステンプレート) |
(C++20) | std::remove_cv と std::remove_reference を合わせたもの (クラステンプレート) |
(C++11) | コンパイル時ブーリアンに基づいて関数オーバーロードまたはテンプレート特殊化を隠蔽します (クラステンプレート) |
(C++11) | コンパイル時ブーリアンに基づいてどちらかの型を選択します (クラステンプレート) |
(C++11) | 指定された型のグループの共通型を調べます (クラステンプレート) |
(C++11) | 指定された列挙型に対する下位層の整数型を取得します (クラステンプレート) |
(C++11)(C++20で削除)(C++17) | 指定された引数のセットを渡して callable なオブジェクトを呼んだときの結果の型を推定します (クラステンプレート) |
(C++17) | void の可変個引数エイリアステンプレート (エイリアステンプレート) |
型特性の演算 | |
(C++17) | 可変個引数の論理積メタ関数 (クラステンプレート) |
(C++17) | 可変個引数の論理和メタ関数 (クラステンプレート) |
(C++17) | 論理否定メタ関数 (クラステンプレート) |
関数 | |
メンバの関係 | |
ある型のオブジェクトがその型の指定された部分オブジェクトとポインタ相互変換可能かどうか調べます (関数テンプレート) | |
(C++20) | 2つの指定されたメンバが2つの指定された型の共通先頭部分列内でお互いに対応するかどうか調べます (関数テンプレート) |
定数評価文脈 | |
(C++20) | 呼び出しが定数評価文脈内で発生したかどうか検出します (関数) |
[編集]概要
namespace std {// helper class:template<class T, T v>struct integral_constant;template<bool B>using bool_constant = integral_constant<bool, B>;using true_type = bool_constant<true>;using false_type = bool_constant<false>; // primary type categories:template<class T>struct is_void;template<class T>struct is_null_pointer;template<class T>struct is_integral;template<class T>struct is_floating_point;template<class T>struct is_array;template<class T>struct is_pointer;template<class T>struct is_lvalue_reference;template<class T>struct is_rvalue_reference;template<class T>struct is_member_object_pointer;template<class T>struct is_member_function_pointer;template<class T>struct is_enum;template<class T>struct is_union;template<class T>struct is_class;template<class T>struct is_function; // composite type categories:template<class T>struct is_reference;template<class T>struct is_arithmetic;template<class T>struct is_fundamental;template<class T>struct is_object;template<class T>struct is_scalar;template<class T>struct is_compound;template<class T>struct is_member_pointer; // type properties:template<class T>struct is_const;template<class T>struct is_volatile;template<class T>struct is_trivial;template<class T>struct is_trivially_copyable;template<class T>struct is_standard_layout;template<class T>struct is_pod;template<class T>struct is_empty;template<class T>struct is_polymorphic;template<class T>struct is_abstract;template<class T>struct is_final;template<class T>struct is_aggregate;template<class T>struct is_signed;template<class T>struct is_unsigned;template<class T>struct is_bounded_array;template<class T>struct is_unbounded_array;template<class T, class... Args>struct is_constructible;template<class T>struct is_default_constructible;template<class T>struct is_copy_constructible;template<class T>struct is_move_constructible;template<class T, class U>struct is_assignable;template<class T>struct is_copy_assignable;template<class T>struct is_move_assignable;template<class T, class U>struct is_swappable_with;template<class T>struct is_swappable;template<class T>struct is_destructible;template<class T, class... Args>struct is_trivially_constructible;template<class T>struct is_trivially_default_constructible;template<class T>struct is_trivially_copy_constructible;template<class T>struct is_trivially_move_constructible;template<class T, class U>struct is_trivially_assignable;template<class T>struct is_trivially_copy_assignable;template<class T>struct is_trivially_move_assignable;template<class T>struct is_trivially_destructible;template<class T, class... Args>struct is_nothrow_constructible;template<class T>struct is_nothrow_default_constructible;template<class T>struct is_nothrow_copy_constructible;template<class T>struct is_nothrow_move_constructible;template<class T, class U>struct is_nothrow_assignable;template<class T>struct is_nothrow_copy_assignable;template<class T>struct is_nothrow_move_assignable;template<class T, class U>struct is_nothrow_swappable_with;template<class T>struct is_nothrow_swappable;template<class T>struct is_nothrow_destructible;template<class T>struct has_virtual_destructor;template<class T>struct has_unique_object_representations; // type property queries:template<class T>struct alignment_of;template<class T>struct rank;template<class T, unsigned I =0>struct extent; // type relations:template<class T, class U>struct is_same;template<class Base, class Derived>struct is_base_of;template<class From, class To>struct is_convertible;template<class From, class To>struct is_nothrow_convertible;template<class T, class U>struct is_layout_compatible;template<class Base, class Derived>struct is_pointer_interconvertible_base_of;template<class Fn, class... ArgTypes>struct is_invocable;template<class R, class Fn, class... ArgTypes>struct is_invocable_r;template<class Fn, class... ArgTypes>struct is_nothrow_invocable;template<class R, class Fn, class... ArgTypes>struct is_nothrow_invocable_r; // const-volatile modifications:template<class T>struct remove_const;template<class T>struct remove_volatile;template<class T>struct remove_cv;template<class T>struct add_const;template<class T>struct add_volatile;template<class T>struct add_cv;template<class T>using remove_const_t =typename remove_const<T>::type;template<class T>using remove_volatile_t =typename remove_volatile<T>::type;template<class T>using remove_cv_t =typename remove_cv<T>::type;template<class T>using add_const_t =typename add_const<T>::type;template<class T>using add_volatile_t =typename add_volatile<T>::type;template<class T>using add_cv_t =typename add_cv<T>::type; // reference modifications:template<class T>struct remove_reference;template<class T>struct add_lvalue_reference;template<class T>struct add_rvalue_reference;template<class T>using remove_reference_t =typename remove_reference<T>::type;template<class T>using add_lvalue_reference_t =typename add_lvalue_reference<T>::type;template<class T>using add_rvalue_reference_t =typename add_rvalue_reference<T>::type; // sign modifications:template<class T>struct make_signed;template<class T>struct make_unsigned;template<class T>using make_signed_t =typename make_signed<T>::type;template<class T>using make_unsigned_t =typename make_unsigned<T>::type; // array modifications:template<class T>struct remove_extent;template<class T>struct remove_all_extents;template<class T>using remove_extent_t =typename remove_extent<T>::type;template<class T>using remove_all_extents_t =typename remove_all_extents<T>::type; // pointer modifications:template<class T>struct remove_pointer;template<class T>struct add_pointer;template<class T>using remove_pointer_t =typename remove_pointer<T>::type;template<class T>using add_pointer_t =typename add_pointer<T>::type; // other transformations:template<size_t Len, size_t Align =/*default-alignment*/>struct aligned_storage;template<size_t Len, class... Types>struct aligned_union;template<class T>struct decay;template<class T>struct remove_cvref;template<bool, class T =void>struct enable_if;template<bool, class T, class F>struct conditional;template<class... T>struct common_type;template<class T>struct underlying_type;template<class>class result_of;// not definedtemplate<class F, class... ArgTypes>class result_of<F(ArgTypes...)>;template<class F, class... ArgTypes>class invoke_result;template<size_t Len, size_t Align =/*default-alignment*/>using aligned_storage_t =typename aligned_storage<Len, Align>::type;template<size_t Len, class... Types>using aligned_union_t =typename aligned_union<Len, Types...>::type;template<class T>using decay_t =typename decay<T>::type;template<class T>using remove_cvref_t =typename remove_cvref<T>::type;template<bool b, class T =void>using enable_if_t =typename enable_if<b, T>::type;template<bool b, class T, class F>using conditional_t =typename conditional<b, T, F>::type;template<class... T>using common_type_t =typename common_type<T...>::type;template<class T>using underlying_type_t =typename underlying_type<T>::type;template<class T>using result_of_t =typename result_of<T>::type;template<class F, class... ArgTypes>using invoke_result_t =typename invoke_result<F, ArgTypes...>::type;template<class...>using void_t =void; // logical operator traits:template<class... B>struct conjunction;template<class... B>struct disjunction;template<class B>struct negation; // primary type categoriestemplate<class T>inlineconstexprbool is_void_v = is_void<T>::value;template<class T>inlineconstexprbool is_null_pointer_v = is_null_pointer<T>::value;template<class T>inlineconstexprbool is_integral_v = is_integral<T>::value;template<class T>inlineconstexprbool is_floating_point_v = is_floating_point<T>::value;template<class T>inlineconstexprbool is_array_v = is_array<T>::value;template<class T>inlineconstexprbool is_pointer_v = is_pointer<T>::value;template<class T>inlineconstexprbool is_lvalue_reference_v = is_lvalue_reference<T>::value;template<class T>inlineconstexprbool is_rvalue_reference_v = is_rvalue_reference<T>::value;template<class T>inlineconstexprbool is_member_object_pointer_v = is_member_object_pointer<T>::value;template<class T>inlineconstexprbool is_member_function_pointer_v = is_member_function_pointer<T>::value;template<class T>inlineconstexprbool is_enum_v = is_enum<T>::value;template<class T>inlineconstexprbool is_union_v = is_union<T>::value;template<class T>inlineconstexprbool is_class_v = is_class<T>::value;template<class T>inlineconstexprbool is_function_v = is_function<T>::value; // composite type categoriestemplate<class T>inlineconstexprbool is_reference_v = is_reference<T>::value;template<class T>inlineconstexprbool is_arithmetic_v = is_arithmetic<T>::value;template<class T>inlineconstexprbool is_fundamental_v = is_fundamental<T>::value;template<class T>inlineconstexprbool is_object_v = is_object<T>::value;template<class T>inlineconstexprbool is_scalar_v = is_scalar<T>::value;template<class T>inlineconstexprbool is_compound_v = is_compound<T>::value;template<class T>inlineconstexprbool is_member_pointer_v = is_member_pointer<T>::value; // type propertiestemplate<class T>inlineconstexprbool is_const_v = is_const<T>::value;template<class T>inlineconstexprbool is_volatile_v = is_volatile<T>::value;template<class T>inlineconstexprbool is_trivial_v = is_trivial<T>::value;template<class T>inlineconstexprbool is_trivially_copyable_v = is_trivially_copyable<T>::value;template<class T>inlineconstexprbool is_standard_layout_v = is_standard_layout<T>::value;template<class T>inlineconstexprbool is_pod_v = is_pod<T>::value;template<class T>inlineconstexprbool is_empty_v = is_empty<T>::value;template<class T>inlineconstexprbool is_polymorphic_v = is_polymorphic<T>::value;template<class T>inlineconstexprbool is_abstract_v = is_abstract<T>::value;template<class T>inlineconstexprbool is_final_v = is_final<T>::value;template<class T>inlineconstexprbool is_aggregate_v = is_aggregate<T>::value;template<class T>inlineconstexprbool is_signed_v = is_signed<T>::value;template<class T>inlineconstexprbool is_unsigned_v = is_unsigned<T>::value;template<class T>inlineconstexprbool is_bounded_array_v = is_bounded_array<T>::value;template<class T>inlineconstexprbool is_unbounded_array_v = is_unbounded_array<T>::value;template<class T, class... Args>inlineconstexprbool is_constructible_v = is_constructible<T, Args...>::value;template<class T>inlineconstexprbool is_default_constructible_v = is_default_constructible<T>::value;template<class T>inlineconstexprbool is_copy_constructible_v = is_copy_constructible<T>::value;template<class T>inlineconstexprbool is_move_constructible_v = is_move_constructible<T>::value;template<class T, class U>inlineconstexprbool is_assignable_v = is_assignable<T, U>::value;template<class T>inlineconstexprbool is_copy_assignable_v = is_copy_assignable<T>::value;template<class T>inlineconstexprbool is_move_assignable_v = is_move_assignable<T>::value;template<class T, class U>inlineconstexprbool is_swappable_with_v = is_swappable_with<T, U>::value;template<class T>inlineconstexprbool is_swappable_v = is_swappable<T>::value;template<class T>inlineconstexprbool is_destructible_v = is_destructible<T>::value;template<class T, class... Args>inlineconstexprbool is_trivially_constructible_v = is_trivially_constructible<T, Args...>::value;template<class T>inlineconstexprbool is_trivially_default_constructible_v = is_trivially_default_constructible<T>::value;template<class T>inlineconstexprbool is_trivially_copy_constructible_v = is_trivially_copy_constructible<T>::value;template<class T>inlineconstexprbool is_trivially_move_constructible_v = is_trivially_move_constructible<T>::value;template<class T, class U>inlineconstexprbool is_trivially_assignable_v = is_trivially_assignable<T, U>::value;template<class T>inlineconstexprbool is_trivially_copy_assignable_v = is_trivially_copy_assignable<T>::value;template<class T>inlineconstexprbool is_trivially_move_assignable_v = is_trivially_move_assignable<T>::value;template<class T>inlineconstexprbool is_trivially_destructible_v = is_trivially_destructible<T>::value;template<class T, class... Args>inlineconstexprbool is_nothrow_constructible_v = is_nothrow_constructible<T, Args...>::value;template<class T>inlineconstexprbool is_nothrow_default_constructible_v = is_nothrow_default_constructible<T>::value;template<class T>inlineconstexprbool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<T>::value;template<class T>inlineconstexprbool is_nothrow_move_constructible_v = is_nothrow_move_constructible<T>::value;template<class T, class U>inlineconstexprbool is_nothrow_assignable_v = is_nothrow_assignable<T, U>::value;template<class T>inlineconstexprbool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<T>::value;template<class T>inlineconstexprbool is_nothrow_move_assignable_v = is_nothrow_move_assignable<T>::value;template<class T, class U>inlineconstexprbool is_nothrow_swappable_with_v = is_nothrow_swappable_with<T, U>::value;template<class T>inlineconstexprbool is_nothrow_swappable_v = is_nothrow_swappable<T>::value;template<class T>inlineconstexprbool is_nothrow_destructible_v = is_nothrow_destructible<T>::value;template<class T>inlineconstexprbool has_virtual_destructor_v = has_virtual_destructor<T>::value;template<class T>inlineconstexprbool has_unique_object_representations_v = has_unique_object_representations<T>::value; // type property queriestemplate<class T>inlineconstexpr size_t alignment_of_v = alignment_of<T>::value;template<class T>inlineconstexpr size_t rank_v = rank<T>::value;template<class T, unsigned I =0>inlineconstexpr size_t extent_v = extent<T, I>::value; // type relationstemplate<class T, class U>inlineconstexprbool is_same_v = is_same<T, U>::value;template<class Base, class Derived>inlineconstexprbool is_base_of_v = is_base_of<Base, Derived>::value;template<class From, class To>inlineconstexprbool is_convertible_v = is_convertible<From, To>::value;template<class From, class To>inlineconstexprbool is_nothrow_convertible_v = is_nothrow_convertible<From, To>::value;template<class T, class U>inlineconstexprbool is_layout_compatible_v = is_layout_compatible<T, U>::value;template<class Base, class Derived>inlineconstexprbool is_pointer_interconvertible_base_of_v = is_pointer_interconvertible_base_of<Base, Derived>::value; template<class Fn, class... ArgTypes>inlineconstexprbool is_invocable_v = is_invocable<Fn, ArgTypes...>::value;template<class R, class Fn, class... ArgTypes>inlineconstexprbool is_invocable_r_v = is_invocable_r<R, Fn, ArgTypes...>::value;template<class Fn, class... ArgTypes>inlineconstexprbool is_nothrow_invocable_v = is_nothrow_invocable<Fn, ArgTypes...>::value;template<class R, class Fn, class... ArgTypes>inlineconstexprbool is_nothrow_invocable_r_v = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // logical operator traits:template<class... B>inlineconstexprbool conjunction_v = conjunction<B...>::value;template<class... B>inlineconstexprbool disjunction_v = disjunction<B...>::value;template<class B>inlineconstexprbool negation_v = negation<B>::value; // member relationshipstemplate<class S, class M>constexprbool is_pointer_interconvertible_with_class(M S::*m)noexcept;template<class S1, class S2, class M1, class M2>constexprbool is_corresponding_member(M1 S1::*m1, M2 S2::*m2)noexcept; // constant evaluation contextconstexprbool is_constant_evaluated()noexcept;}// namespace std
[編集]クラステンプレート std::integral_constant
namespace std {template<class T, T v>struct integral_constant {staticconstexpr T value = v;using value_type = T;using type = integral_constant<T, v>;constexpr operator value_type()constnoexcept{return value;}constexpr value_type operator()()constnoexcept{return value;}};}