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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Metaprogramming and type traits <a id="type.traits">[[type.traits]]</a>
|
| 2 |
+
|
| 3 |
+
### General <a id="type.traits.general">[[type.traits.general]]</a>
|
| 4 |
+
|
| 5 |
+
Subclause [[type.traits]] describes components used by C++ programs,
|
| 6 |
+
particularly in templates, to support the widest possible range of
|
| 7 |
+
types, optimize template code usage, detect type related user errors,
|
| 8 |
+
and perform type inference and transformation at compile time. It
|
| 9 |
+
includes type classification traits, type property inspection traits,
|
| 10 |
+
and type transformations. The type classification traits describe a
|
| 11 |
+
complete taxonomy of all possible C++ types, and state where in that
|
| 12 |
+
taxonomy a given type belongs. The type property inspection traits allow
|
| 13 |
+
important characteristics of types or of combinations of types to be
|
| 14 |
+
inspected. The type transformations allow certain properties of types to
|
| 15 |
+
be manipulated.
|
| 16 |
+
|
| 17 |
+
All functions specified in [[type.traits]] are signal-safe
|
| 18 |
+
[[support.signal]].
|
| 19 |
+
|
| 20 |
+
### Requirements <a id="meta.rqmts">[[meta.rqmts]]</a>
|
| 21 |
+
|
| 22 |
+
A describes a property of a type. It shall be a class template that
|
| 23 |
+
takes one template type argument and, optionally, additional arguments
|
| 24 |
+
that help define the property being described. It shall be
|
| 25 |
+
*Cpp17DefaultConstructible*, *Cpp17CopyConstructible*, and publicly and
|
| 26 |
+
unambiguously derived, directly or indirectly, from its *base
|
| 27 |
+
characteristic*, which is a specialization of the template
|
| 28 |
+
`integral_constant` [[meta.help]], with the arguments to the template
|
| 29 |
+
`integral_constant` determined by the requirements for the particular
|
| 30 |
+
property being described. The member names of the base characteristic
|
| 31 |
+
shall not be hidden and shall be unambiguously available in the
|
| 32 |
+
*Cpp17UnaryTypeTrait*.
|
| 33 |
+
|
| 34 |
+
A describes a relationship between two types. It shall be a class
|
| 35 |
+
template that takes two template type arguments and, optionally,
|
| 36 |
+
additional arguments that help define the relationship being described.
|
| 37 |
+
It shall be *Cpp17DefaultConstructible*, *Cpp17CopyConstructible*, and
|
| 38 |
+
publicly and unambiguously derived, directly or indirectly, from its
|
| 39 |
+
*base characteristic*, which is a specialization of the template
|
| 40 |
+
`integral_constant` [[meta.help]], with the arguments to the template
|
| 41 |
+
`integral_constant` determined by the requirements for the particular
|
| 42 |
+
relationship being described. The member names of the base
|
| 43 |
+
characteristic shall not be hidden and shall be unambiguously available
|
| 44 |
+
in the *Cpp17BinaryTypeTrait*.
|
| 45 |
+
|
| 46 |
+
A modifies a property of a type. It shall be a class template that takes
|
| 47 |
+
one template type argument and, optionally, additional arguments that
|
| 48 |
+
help define the modification. It shall define a publicly accessible
|
| 49 |
+
nested type named `type`, which shall be a synonym for the modified
|
| 50 |
+
type.
|
| 51 |
+
|
| 52 |
+
Unless otherwise specified, the behavior of a program that adds
|
| 53 |
+
specializations for any of the templates specified in [[type.traits]] is
|
| 54 |
+
undefined.
|
| 55 |
+
|
| 56 |
+
Unless otherwise specified, an incomplete type may be used to
|
| 57 |
+
instantiate a template specified in [[type.traits]]. The behavior of a
|
| 58 |
+
program is undefined if:
|
| 59 |
+
|
| 60 |
+
- an instantiation of a template specified in [[type.traits]] directly
|
| 61 |
+
or indirectly depends on an incompletely-defined object type `T`, and
|
| 62 |
+
- that instantiation could yield a different result were `T`
|
| 63 |
+
hypothetically completed.
|
| 64 |
+
|
| 65 |
+
### Header `<type_traits>` synopsis <a id="meta.type.synop">[[meta.type.synop]]</a>
|
| 66 |
+
|
| 67 |
+
``` cpp
|
| 68 |
+
// all freestanding
|
| 69 |
+
namespace std {
|
| 70 |
+
// [meta.help], helper class
|
| 71 |
+
template<class T, T v> struct integral_constant;
|
| 72 |
+
|
| 73 |
+
template<bool B>
|
| 74 |
+
using bool_constant = integral_constant<bool, B>;
|
| 75 |
+
using true_type = bool_constant<true>;
|
| 76 |
+
using false_type = bool_constant<false>;
|
| 77 |
+
|
| 78 |
+
// [meta.unary.cat], primary type categories
|
| 79 |
+
template<class T> struct is_void;
|
| 80 |
+
template<class T> struct is_null_pointer;
|
| 81 |
+
template<class T> struct is_integral;
|
| 82 |
+
template<class T> struct is_floating_point;
|
| 83 |
+
template<class T> struct is_array;
|
| 84 |
+
template<class T> struct is_pointer;
|
| 85 |
+
template<class T> struct is_lvalue_reference;
|
| 86 |
+
template<class T> struct is_rvalue_reference;
|
| 87 |
+
template<class T> struct is_member_object_pointer;
|
| 88 |
+
template<class T> struct is_member_function_pointer;
|
| 89 |
+
template<class T> struct is_enum;
|
| 90 |
+
template<class T> struct is_union;
|
| 91 |
+
template<class T> struct is_class;
|
| 92 |
+
template<class T> struct is_function;
|
| 93 |
+
|
| 94 |
+
// [meta.unary.comp], composite type categories
|
| 95 |
+
template<class T> struct is_reference;
|
| 96 |
+
template<class T> struct is_arithmetic;
|
| 97 |
+
template<class T> struct is_fundamental;
|
| 98 |
+
template<class T> struct is_object;
|
| 99 |
+
template<class T> struct is_scalar;
|
| 100 |
+
template<class T> struct is_compound;
|
| 101 |
+
template<class T> struct is_member_pointer;
|
| 102 |
+
|
| 103 |
+
// [meta.unary.prop], type properties
|
| 104 |
+
template<class T> struct is_const;
|
| 105 |
+
template<class T> struct is_volatile;
|
| 106 |
+
template<class T> struct is_trivial;
|
| 107 |
+
template<class T> struct is_trivially_copyable;
|
| 108 |
+
template<class T> struct is_standard_layout;
|
| 109 |
+
template<class T> struct is_empty;
|
| 110 |
+
template<class T> struct is_polymorphic;
|
| 111 |
+
template<class T> struct is_abstract;
|
| 112 |
+
template<class T> struct is_final;
|
| 113 |
+
template<class T> struct is_aggregate;
|
| 114 |
+
|
| 115 |
+
template<class T> struct is_signed;
|
| 116 |
+
template<class T> struct is_unsigned;
|
| 117 |
+
template<class T> struct is_bounded_array;
|
| 118 |
+
template<class T> struct is_unbounded_array;
|
| 119 |
+
template<class T> struct is_scoped_enum;
|
| 120 |
+
|
| 121 |
+
template<class T, class... Args> struct is_constructible;
|
| 122 |
+
template<class T> struct is_default_constructible;
|
| 123 |
+
template<class T> struct is_copy_constructible;
|
| 124 |
+
template<class T> struct is_move_constructible;
|
| 125 |
+
|
| 126 |
+
template<class T, class U> struct is_assignable;
|
| 127 |
+
template<class T> struct is_copy_assignable;
|
| 128 |
+
template<class T> struct is_move_assignable;
|
| 129 |
+
|
| 130 |
+
template<class T, class U> struct is_swappable_with;
|
| 131 |
+
template<class T> struct is_swappable;
|
| 132 |
+
|
| 133 |
+
template<class T> struct is_destructible;
|
| 134 |
+
|
| 135 |
+
template<class T, class... Args> struct is_trivially_constructible;
|
| 136 |
+
template<class T> struct is_trivially_default_constructible;
|
| 137 |
+
template<class T> struct is_trivially_copy_constructible;
|
| 138 |
+
template<class T> struct is_trivially_move_constructible;
|
| 139 |
+
|
| 140 |
+
template<class T, class U> struct is_trivially_assignable;
|
| 141 |
+
template<class T> struct is_trivially_copy_assignable;
|
| 142 |
+
template<class T> struct is_trivially_move_assignable;
|
| 143 |
+
template<class T> struct is_trivially_destructible;
|
| 144 |
+
|
| 145 |
+
template<class T, class... Args> struct is_nothrow_constructible;
|
| 146 |
+
template<class T> struct is_nothrow_default_constructible;
|
| 147 |
+
template<class T> struct is_nothrow_copy_constructible;
|
| 148 |
+
template<class T> struct is_nothrow_move_constructible;
|
| 149 |
+
|
| 150 |
+
template<class T, class U> struct is_nothrow_assignable;
|
| 151 |
+
template<class T> struct is_nothrow_copy_assignable;
|
| 152 |
+
template<class T> struct is_nothrow_move_assignable;
|
| 153 |
+
|
| 154 |
+
template<class T, class U> struct is_nothrow_swappable_with;
|
| 155 |
+
template<class T> struct is_nothrow_swappable;
|
| 156 |
+
|
| 157 |
+
template<class T> struct is_nothrow_destructible;
|
| 158 |
+
|
| 159 |
+
template<class T> struct is_implicit_lifetime;
|
| 160 |
+
|
| 161 |
+
template<class T> struct has_virtual_destructor;
|
| 162 |
+
|
| 163 |
+
template<class T> struct has_unique_object_representations;
|
| 164 |
+
|
| 165 |
+
template<class T, class U> struct reference_constructs_from_temporary;
|
| 166 |
+
template<class T, class U> struct reference_converts_from_temporary;
|
| 167 |
+
|
| 168 |
+
// [meta.unary.prop.query], type property queries
|
| 169 |
+
template<class T> struct alignment_of;
|
| 170 |
+
template<class T> struct rank;
|
| 171 |
+
template<class T, unsigned I = 0> struct extent;
|
| 172 |
+
|
| 173 |
+
// [meta.rel], type relations
|
| 174 |
+
template<class T, class U> struct is_same;
|
| 175 |
+
template<class Base, class Derived> struct is_base_of;
|
| 176 |
+
template<class From, class To> struct is_convertible;
|
| 177 |
+
template<class From, class To> struct is_nothrow_convertible;
|
| 178 |
+
template<class T, class U> struct is_layout_compatible;
|
| 179 |
+
template<class Base, class Derived> struct is_pointer_interconvertible_base_of;
|
| 180 |
+
|
| 181 |
+
template<class Fn, class... ArgTypes> struct is_invocable;
|
| 182 |
+
template<class R, class Fn, class... ArgTypes> struct is_invocable_r;
|
| 183 |
+
|
| 184 |
+
template<class Fn, class... ArgTypes> struct is_nothrow_invocable;
|
| 185 |
+
template<class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
|
| 186 |
+
|
| 187 |
+
// [meta.trans.cv], const-volatile modifications
|
| 188 |
+
template<class T> struct remove_const;
|
| 189 |
+
template<class T> struct remove_volatile;
|
| 190 |
+
template<class T> struct remove_cv;
|
| 191 |
+
template<class T> struct add_const;
|
| 192 |
+
template<class T> struct add_volatile;
|
| 193 |
+
template<class T> struct add_cv;
|
| 194 |
+
|
| 195 |
+
template<class T>
|
| 196 |
+
using remove_const_t = typename remove_const<T>::type;
|
| 197 |
+
template<class T>
|
| 198 |
+
using remove_volatile_t = typename remove_volatile<T>::type;
|
| 199 |
+
template<class T>
|
| 200 |
+
using remove_cv_t = typename remove_cv<T>::type;
|
| 201 |
+
template<class T>
|
| 202 |
+
using add_const_t = typename add_const<T>::type;
|
| 203 |
+
template<class T>
|
| 204 |
+
using add_volatile_t = typename add_volatile<T>::type;
|
| 205 |
+
template<class T>
|
| 206 |
+
using add_cv_t = typename add_cv<T>::type;
|
| 207 |
+
|
| 208 |
+
// [meta.trans.ref], reference modifications
|
| 209 |
+
template<class T> struct remove_reference;
|
| 210 |
+
template<class T> struct add_lvalue_reference;
|
| 211 |
+
template<class T> struct add_rvalue_reference;
|
| 212 |
+
|
| 213 |
+
template<class T>
|
| 214 |
+
using remove_reference_t = typename remove_reference<T>::type;
|
| 215 |
+
template<class T>
|
| 216 |
+
using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
|
| 217 |
+
template<class T>
|
| 218 |
+
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
|
| 219 |
+
|
| 220 |
+
// [meta.trans.sign], sign modifications
|
| 221 |
+
template<class T> struct make_signed;
|
| 222 |
+
template<class T> struct make_unsigned;
|
| 223 |
+
|
| 224 |
+
template<class T>
|
| 225 |
+
using make_signed_t = typename make_signed<T>::type;
|
| 226 |
+
template<class T>
|
| 227 |
+
using make_unsigned_t = typename make_unsigned<T>::type;
|
| 228 |
+
|
| 229 |
+
// [meta.trans.arr], array modifications
|
| 230 |
+
template<class T> struct remove_extent;
|
| 231 |
+
template<class T> struct remove_all_extents;
|
| 232 |
+
|
| 233 |
+
template<class T>
|
| 234 |
+
using remove_extent_t = typename remove_extent<T>::type;
|
| 235 |
+
template<class T>
|
| 236 |
+
using remove_all_extents_t = typename remove_all_extents<T>::type;
|
| 237 |
+
|
| 238 |
+
// [meta.trans.ptr], pointer modifications
|
| 239 |
+
template<class T> struct remove_pointer;
|
| 240 |
+
template<class T> struct add_pointer;
|
| 241 |
+
|
| 242 |
+
template<class T>
|
| 243 |
+
using remove_pointer_t = typename remove_pointer<T>::type;
|
| 244 |
+
template<class T>
|
| 245 |
+
using add_pointer_t = typename add_pointer<T>::type;
|
| 246 |
+
|
| 247 |
+
// [meta.trans.other], other transformations
|
| 248 |
+
template<class T> struct type_identity;
|
| 249 |
+
template<class T> struct remove_cvref;
|
| 250 |
+
template<class T> struct decay;
|
| 251 |
+
template<bool, class T = void> struct enable_if;
|
| 252 |
+
template<bool, class T, class F> struct conditional;
|
| 253 |
+
template<class... T> struct common_type;
|
| 254 |
+
template<class T, class U, template<class> class TQual, template<class> class UQual>
|
| 255 |
+
struct basic_common_reference { };
|
| 256 |
+
template<class... T> struct common_reference;
|
| 257 |
+
template<class T> struct underlying_type;
|
| 258 |
+
template<class Fn, class... ArgTypes> struct invoke_result;
|
| 259 |
+
template<class T> struct unwrap_reference;
|
| 260 |
+
template<class T> struct unwrap_ref_decay;
|
| 261 |
+
|
| 262 |
+
template<class T>
|
| 263 |
+
using type_identity_t = typename type_identity<T>::type;
|
| 264 |
+
template<class T>
|
| 265 |
+
using remove_cvref_t = typename remove_cvref<T>::type;
|
| 266 |
+
template<class T>
|
| 267 |
+
using decay_t = typename decay<T>::type;
|
| 268 |
+
template<bool B, class T = void>
|
| 269 |
+
using enable_if_t = typename enable_if<B, T>::type;
|
| 270 |
+
template<bool B, class T, class F>
|
| 271 |
+
using conditional_t = typename conditional<B, T, F>::type;
|
| 272 |
+
template<class... T>
|
| 273 |
+
using common_type_t = typename common_type<T...>::type;
|
| 274 |
+
template<class... T>
|
| 275 |
+
using common_reference_t = typename common_reference<T...>::type;
|
| 276 |
+
template<class T>
|
| 277 |
+
using underlying_type_t = typename underlying_type<T>::type;
|
| 278 |
+
template<class Fn, class... ArgTypes>
|
| 279 |
+
using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type;
|
| 280 |
+
template<class T>
|
| 281 |
+
using unwrap_reference_t = typename unwrap_reference<T>::type;
|
| 282 |
+
template<class T>
|
| 283 |
+
using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type;
|
| 284 |
+
template<class...>
|
| 285 |
+
using void_t = void;
|
| 286 |
+
|
| 287 |
+
// [meta.logical], logical operator traits
|
| 288 |
+
template<class... B> struct conjunction;
|
| 289 |
+
template<class... B> struct disjunction;
|
| 290 |
+
template<class B> struct negation;
|
| 291 |
+
|
| 292 |
+
// [meta.unary.cat], primary type categories
|
| 293 |
+
template<class T>
|
| 294 |
+
constexpr bool is_void_v = is_void<T>::value;
|
| 295 |
+
template<class T>
|
| 296 |
+
constexpr bool is_null_pointer_v = is_null_pointer<T>::value;
|
| 297 |
+
template<class T>
|
| 298 |
+
constexpr bool is_integral_v = is_integral<T>::value;
|
| 299 |
+
template<class T>
|
| 300 |
+
constexpr bool is_floating_point_v = is_floating_point<T>::value;
|
| 301 |
+
template<class T>
|
| 302 |
+
constexpr bool is_array_v = is_array<T>::value;
|
| 303 |
+
template<class T>
|
| 304 |
+
constexpr bool is_pointer_v = is_pointer<T>::value;
|
| 305 |
+
template<class T>
|
| 306 |
+
constexpr bool is_lvalue_reference_v = is_lvalue_reference<T>::value;
|
| 307 |
+
template<class T>
|
| 308 |
+
constexpr bool is_rvalue_reference_v = is_rvalue_reference<T>::value;
|
| 309 |
+
template<class T>
|
| 310 |
+
constexpr bool is_member_object_pointer_v = is_member_object_pointer<T>::value;
|
| 311 |
+
template<class T>
|
| 312 |
+
constexpr bool is_member_function_pointer_v = is_member_function_pointer<T>::value;
|
| 313 |
+
template<class T>
|
| 314 |
+
constexpr bool is_enum_v = is_enum<T>::value;
|
| 315 |
+
template<class T>
|
| 316 |
+
constexpr bool is_union_v = is_union<T>::value;
|
| 317 |
+
template<class T>
|
| 318 |
+
constexpr bool is_class_v = is_class<T>::value;
|
| 319 |
+
template<class T>
|
| 320 |
+
constexpr bool is_function_v = is_function<T>::value;
|
| 321 |
+
|
| 322 |
+
// [meta.unary.comp], composite type categories
|
| 323 |
+
template<class T>
|
| 324 |
+
constexpr bool is_reference_v = is_reference<T>::value;
|
| 325 |
+
template<class T>
|
| 326 |
+
constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
|
| 327 |
+
template<class T>
|
| 328 |
+
constexpr bool is_fundamental_v = is_fundamental<T>::value;
|
| 329 |
+
template<class T>
|
| 330 |
+
constexpr bool is_object_v = is_object<T>::value;
|
| 331 |
+
template<class T>
|
| 332 |
+
constexpr bool is_scalar_v = is_scalar<T>::value;
|
| 333 |
+
template<class T>
|
| 334 |
+
constexpr bool is_compound_v = is_compound<T>::value;
|
| 335 |
+
template<class T>
|
| 336 |
+
constexpr bool is_member_pointer_v = is_member_pointer<T>::value;
|
| 337 |
+
|
| 338 |
+
// [meta.unary.prop], type properties
|
| 339 |
+
template<class T>
|
| 340 |
+
constexpr bool is_const_v = is_const<T>::value;
|
| 341 |
+
template<class T>
|
| 342 |
+
constexpr bool is_volatile_v = is_volatile<T>::value;
|
| 343 |
+
template<class T>
|
| 344 |
+
constexpr bool is_trivial_v = is_trivial<T>::value;
|
| 345 |
+
template<class T>
|
| 346 |
+
constexpr bool is_trivially_copyable_v = is_trivially_copyable<T>::value;
|
| 347 |
+
template<class T>
|
| 348 |
+
constexpr bool is_standard_layout_v = is_standard_layout<T>::value;
|
| 349 |
+
template<class T>
|
| 350 |
+
constexpr bool is_empty_v = is_empty<T>::value;
|
| 351 |
+
template<class T>
|
| 352 |
+
constexpr bool is_polymorphic_v = is_polymorphic<T>::value;
|
| 353 |
+
template<class T>
|
| 354 |
+
constexpr bool is_abstract_v = is_abstract<T>::value;
|
| 355 |
+
template<class T>
|
| 356 |
+
constexpr bool is_final_v = is_final<T>::value;
|
| 357 |
+
template<class T>
|
| 358 |
+
constexpr bool is_aggregate_v = is_aggregate<T>::value;
|
| 359 |
+
template<class T>
|
| 360 |
+
constexpr bool is_signed_v = is_signed<T>::value;
|
| 361 |
+
template<class T>
|
| 362 |
+
constexpr bool is_unsigned_v = is_unsigned<T>::value;
|
| 363 |
+
template<class T>
|
| 364 |
+
constexpr bool is_bounded_array_v = is_bounded_array<T>::value;
|
| 365 |
+
template<class T>
|
| 366 |
+
constexpr bool is_unbounded_array_v = is_unbounded_array<T>::value;
|
| 367 |
+
template<class T>
|
| 368 |
+
constexpr bool is_scoped_enum_v = is_scoped_enum<T>::value;
|
| 369 |
+
template<class T, class... Args>
|
| 370 |
+
constexpr bool is_constructible_v = is_constructible<T, Args...>::value;
|
| 371 |
+
template<class T>
|
| 372 |
+
constexpr bool is_default_constructible_v = is_default_constructible<T>::value;
|
| 373 |
+
template<class T>
|
| 374 |
+
constexpr bool is_copy_constructible_v = is_copy_constructible<T>::value;
|
| 375 |
+
template<class T>
|
| 376 |
+
constexpr bool is_move_constructible_v = is_move_constructible<T>::value;
|
| 377 |
+
template<class T, class U>
|
| 378 |
+
constexpr bool is_assignable_v = is_assignable<T, U>::value;
|
| 379 |
+
template<class T>
|
| 380 |
+
constexpr bool is_copy_assignable_v = is_copy_assignable<T>::value;
|
| 381 |
+
template<class T>
|
| 382 |
+
constexpr bool is_move_assignable_v = is_move_assignable<T>::value;
|
| 383 |
+
template<class T, class U>
|
| 384 |
+
constexpr bool is_swappable_with_v = is_swappable_with<T, U>::value;
|
| 385 |
+
template<class T>
|
| 386 |
+
constexpr bool is_swappable_v = is_swappable<T>::value;
|
| 387 |
+
template<class T>
|
| 388 |
+
constexpr bool is_destructible_v = is_destructible<T>::value;
|
| 389 |
+
template<class T, class... Args>
|
| 390 |
+
constexpr bool is_trivially_constructible_v
|
| 391 |
+
= is_trivially_constructible<T, Args...>::value;
|
| 392 |
+
template<class T>
|
| 393 |
+
constexpr bool is_trivially_default_constructible_v
|
| 394 |
+
= is_trivially_default_constructible<T>::value;
|
| 395 |
+
template<class T>
|
| 396 |
+
constexpr bool is_trivially_copy_constructible_v
|
| 397 |
+
= is_trivially_copy_constructible<T>::value;
|
| 398 |
+
template<class T>
|
| 399 |
+
constexpr bool is_trivially_move_constructible_v
|
| 400 |
+
= is_trivially_move_constructible<T>::value;
|
| 401 |
+
template<class T, class U>
|
| 402 |
+
constexpr bool is_trivially_assignable_v = is_trivially_assignable<T, U>::value;
|
| 403 |
+
template<class T>
|
| 404 |
+
constexpr bool is_trivially_copy_assignable_v
|
| 405 |
+
= is_trivially_copy_assignable<T>::value;
|
| 406 |
+
template<class T>
|
| 407 |
+
constexpr bool is_trivially_move_assignable_v
|
| 408 |
+
= is_trivially_move_assignable<T>::value;
|
| 409 |
+
template<class T>
|
| 410 |
+
constexpr bool is_trivially_destructible_v = is_trivially_destructible<T>::value;
|
| 411 |
+
template<class T, class... Args>
|
| 412 |
+
constexpr bool is_nothrow_constructible_v
|
| 413 |
+
= is_nothrow_constructible<T, Args...>::value;
|
| 414 |
+
template<class T>
|
| 415 |
+
constexpr bool is_nothrow_default_constructible_v
|
| 416 |
+
= is_nothrow_default_constructible<T>::value;
|
| 417 |
+
template<class T>
|
| 418 |
+
constexpr bool is_nothrow_copy_constructible_v
|
| 419 |
+
= is_nothrow_copy_constructible<T>::value;
|
| 420 |
+
template<class T>
|
| 421 |
+
constexpr bool is_nothrow_move_constructible_v
|
| 422 |
+
= is_nothrow_move_constructible<T>::value;
|
| 423 |
+
template<class T, class U>
|
| 424 |
+
constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<T, U>::value;
|
| 425 |
+
template<class T>
|
| 426 |
+
constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<T>::value;
|
| 427 |
+
template<class T>
|
| 428 |
+
constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<T>::value;
|
| 429 |
+
template<class T, class U>
|
| 430 |
+
constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<T, U>::value;
|
| 431 |
+
template<class T>
|
| 432 |
+
constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<T>::value;
|
| 433 |
+
template<class T>
|
| 434 |
+
constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<T>::value;
|
| 435 |
+
template<class T>
|
| 436 |
+
constexpr bool is_implicit_lifetime_v = is_implicit_lifetime<T>::value;
|
| 437 |
+
template<class T>
|
| 438 |
+
constexpr bool has_virtual_destructor_v = has_virtual_destructor<T>::value;
|
| 439 |
+
template<class T>
|
| 440 |
+
constexpr bool has_unique_object_representations_v
|
| 441 |
+
= has_unique_object_representations<T>::value;
|
| 442 |
+
template<class T, class U>
|
| 443 |
+
constexpr bool reference_constructs_from_temporary_v
|
| 444 |
+
= reference_constructs_from_temporary<T, U>::value;
|
| 445 |
+
template<class T, class U>
|
| 446 |
+
constexpr bool reference_converts_from_temporary_v
|
| 447 |
+
= reference_converts_from_temporary<T, U>::value;
|
| 448 |
+
|
| 449 |
+
// [meta.unary.prop.query], type property queries
|
| 450 |
+
template<class T>
|
| 451 |
+
constexpr size_t alignment_of_v = alignment_of<T>::value;
|
| 452 |
+
template<class T>
|
| 453 |
+
constexpr size_t rank_v = rank<T>::value;
|
| 454 |
+
template<class T, unsigned I = 0>
|
| 455 |
+
constexpr size_t extent_v = extent<T, I>::value;
|
| 456 |
+
|
| 457 |
+
// [meta.rel], type relations
|
| 458 |
+
template<class T, class U>
|
| 459 |
+
constexpr bool is_same_v = is_same<T, U>::value;
|
| 460 |
+
template<class Base, class Derived>
|
| 461 |
+
constexpr bool is_base_of_v = is_base_of<Base, Derived>::value;
|
| 462 |
+
template<class From, class To>
|
| 463 |
+
constexpr bool is_convertible_v = is_convertible<From, To>::value;
|
| 464 |
+
template<class From, class To>
|
| 465 |
+
constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<From, To>::value;
|
| 466 |
+
template<class T, class U>
|
| 467 |
+
constexpr bool is_layout_compatible_v = is_layout_compatible<T, U>::value;
|
| 468 |
+
template<class Base, class Derived>
|
| 469 |
+
constexpr bool is_pointer_interconvertible_base_of_v
|
| 470 |
+
= is_pointer_interconvertible_base_of<Base, Derived>::value;
|
| 471 |
+
template<class Fn, class... ArgTypes>
|
| 472 |
+
constexpr bool is_invocable_v = is_invocable<Fn, ArgTypes...>::value;
|
| 473 |
+
template<class R, class Fn, class... ArgTypes>
|
| 474 |
+
constexpr bool is_invocable_r_v = is_invocable_r<R, Fn, ArgTypes...>::value;
|
| 475 |
+
template<class Fn, class... ArgTypes>
|
| 476 |
+
constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<Fn, ArgTypes...>::value;
|
| 477 |
+
template<class R, class Fn, class... ArgTypes>
|
| 478 |
+
constexpr bool is_nothrow_invocable_r_v
|
| 479 |
+
= is_nothrow_invocable_r<R, Fn, ArgTypes...>::value;
|
| 480 |
+
|
| 481 |
+
// [meta.logical], logical operator traits
|
| 482 |
+
template<class... B>
|
| 483 |
+
constexpr bool conjunction_v = conjunction<B...>::value;
|
| 484 |
+
template<class... B>
|
| 485 |
+
constexpr bool disjunction_v = disjunction<B...>::value;
|
| 486 |
+
template<class B>
|
| 487 |
+
constexpr bool negation_v = negation<B>::value;
|
| 488 |
+
|
| 489 |
+
// [meta.member], member relationships
|
| 490 |
+
template<class S, class M>
|
| 491 |
+
constexpr bool is_pointer_interconvertible_with_class(M S::*m) noexcept;
|
| 492 |
+
template<class S1, class S2, class M1, class M2>
|
| 493 |
+
constexpr bool is_corresponding_member(M1 S1::*m1, M2 S2::*m2) noexcept;
|
| 494 |
+
|
| 495 |
+
// [meta.const.eval], constant evaluation context
|
| 496 |
+
constexpr bool is_constant_evaluated() noexcept;
|
| 497 |
+
}
|
| 498 |
+
```
|
| 499 |
+
|
| 500 |
+
### Helper classes <a id="meta.help">[[meta.help]]</a>
|
| 501 |
+
|
| 502 |
+
``` cpp
|
| 503 |
+
namespace std {
|
| 504 |
+
template<class T, T v> struct integral_constant {
|
| 505 |
+
static constexpr T value = v;
|
| 506 |
+
|
| 507 |
+
using value_type = T;
|
| 508 |
+
using type = integral_constant<T, v>;
|
| 509 |
+
|
| 510 |
+
constexpr operator value_type() const noexcept { return value; }
|
| 511 |
+
constexpr value_type operator()() const noexcept { return value; }
|
| 512 |
+
};
|
| 513 |
+
}
|
| 514 |
+
```
|
| 515 |
+
|
| 516 |
+
The class template `integral_constant`, alias template `bool_constant`,
|
| 517 |
+
and its associated *typedef-name*s `true_type` and `false_type` are used
|
| 518 |
+
as base classes to define the interface for various type traits.
|
| 519 |
+
|
| 520 |
+
### Unary type traits <a id="meta.unary">[[meta.unary]]</a>
|
| 521 |
+
|
| 522 |
+
#### General <a id="meta.unary.general">[[meta.unary.general]]</a>
|
| 523 |
+
|
| 524 |
+
Subclause [[meta.unary]] contains templates that may be used to query
|
| 525 |
+
the properties of a type at compile time.
|
| 526 |
+
|
| 527 |
+
Each of these templates shall be a *Cpp17UnaryTypeTrait* [[meta.rqmts]]
|
| 528 |
+
with a base characteristic of `true_type` if the corresponding condition
|
| 529 |
+
is `true`, otherwise `false_type`.
|
| 530 |
+
|
| 531 |
+
#### Primary type categories <a id="meta.unary.cat">[[meta.unary.cat]]</a>
|
| 532 |
+
|
| 533 |
+
The primary type categories correspond to the descriptions given in
|
| 534 |
+
subclause [[basic.types]] of the C++ standard.
|
| 535 |
+
|
| 536 |
+
For any given type `T`, the result of applying one of these templates to
|
| 537 |
+
`T` and to cv `T` shall yield the same result.
|
| 538 |
+
|
| 539 |
+
[*Note 1*: For any given type `T`, exactly one of the primary type
|
| 540 |
+
categories has a `value` member that evaluates to `true`. — *end note*]
|
| 541 |
+
|
| 542 |
+
#### Composite type traits <a id="meta.unary.comp">[[meta.unary.comp]]</a>
|
| 543 |
+
|
| 544 |
+
These templates provide convenient compositions of the primary type
|
| 545 |
+
categories, corresponding to the descriptions given in subclause
|
| 546 |
+
[[basic.types]].
|
| 547 |
+
|
| 548 |
+
For any given type `T`, the result of applying one of these templates to
|
| 549 |
+
`T` and to cv `T` shall yield the same result.
|
| 550 |
+
|
| 551 |
+
#### Type properties <a id="meta.unary.prop">[[meta.unary.prop]]</a>
|
| 552 |
+
|
| 553 |
+
These templates provide access to some of the more important properties
|
| 554 |
+
of types.
|
| 555 |
+
|
| 556 |
+
It is unspecified whether the library defines any full or partial
|
| 557 |
+
specializations of any of these templates.
|
| 558 |
+
|
| 559 |
+
For all of the class templates `X` declared in this subclause,
|
| 560 |
+
instantiating that template with a template-argument that is a class
|
| 561 |
+
template specialization may result in the implicit instantiation of the
|
| 562 |
+
template argument if and only if the semantics of `X` require that the
|
| 563 |
+
argument is a complete type.
|
| 564 |
+
|
| 565 |
+
For the purpose of defining the templates in this subclause, a function
|
| 566 |
+
call expression `declval<T>()` for any type `T` is considered to be a
|
| 567 |
+
trivial [[term.trivial.type]], [[special]] function call that is not an
|
| 568 |
+
odr-use [[term.odr.use]] of `declval` in the context of the
|
| 569 |
+
corresponding definition notwithstanding the restrictions of
|
| 570 |
+
[[declval]].
|
| 571 |
+
|
| 572 |
+
For the purpose of defining the templates in this subclause, let
|
| 573 |
+
`VAL<T>` for some type `T` be an expression defined as follows:
|
| 574 |
+
|
| 575 |
+
- If `T` is a reference or function type, `VAL<T>` is an expression with
|
| 576 |
+
the same type and value category as `declval<T>()`.
|
| 577 |
+
- Otherwise, `VAL<T>` is a prvalue that initially has type `T`.
|
| 578 |
+
\[*Note 1*: If `T` is cv-qualified, the cv-qualification is subject to
|
| 579 |
+
adjustment [[expr.type]]. — *end note*]
|
| 580 |
+
|
| 581 |
+
[*Example 1*:
|
| 582 |
+
|
| 583 |
+
``` cpp
|
| 584 |
+
is_const_v<const volatile int> // true
|
| 585 |
+
is_const_v<const int*> // false
|
| 586 |
+
is_const_v<const int&> // false
|
| 587 |
+
is_const_v<int[3]> // false
|
| 588 |
+
is_const_v<const int[3]> // true
|
| 589 |
+
```
|
| 590 |
+
|
| 591 |
+
— *end example*]
|
| 592 |
+
|
| 593 |
+
[*Example 2*:
|
| 594 |
+
|
| 595 |
+
``` cpp
|
| 596 |
+
remove_const_t<const volatile int> // volatile int
|
| 597 |
+
remove_const_t<const int* const> // const int*
|
| 598 |
+
remove_const_t<const int&> // const int&
|
| 599 |
+
remove_const_t<const int[3]> // int[3]
|
| 600 |
+
```
|
| 601 |
+
|
| 602 |
+
— *end example*]
|
| 603 |
+
|
| 604 |
+
[*Example 3*:
|
| 605 |
+
|
| 606 |
+
``` cpp
|
| 607 |
+
// Given:
|
| 608 |
+
struct P final { };
|
| 609 |
+
union U1 { };
|
| 610 |
+
union U2 final { };
|
| 611 |
+
|
| 612 |
+
// the following assertions hold:
|
| 613 |
+
static_assert(!is_final_v<int>);
|
| 614 |
+
static_assert(is_final_v<P>);
|
| 615 |
+
static_assert(!is_final_v<U1>);
|
| 616 |
+
static_assert(is_final_v<U2>);
|
| 617 |
+
```
|
| 618 |
+
|
| 619 |
+
— *end example*]
|
| 620 |
+
|
| 621 |
+
The predicate condition for a template specialization
|
| 622 |
+
`is_constructible<T, Args...>` shall be satisfied if and only if the
|
| 623 |
+
following variable definition would be well-formed for some invented
|
| 624 |
+
variable `t`:
|
| 625 |
+
|
| 626 |
+
``` cpp
|
| 627 |
+
T t(declval<Args>()...);
|
| 628 |
+
```
|
| 629 |
+
|
| 630 |
+
[*Note 2*: These tokens are never interpreted as a function
|
| 631 |
+
declaration. — *end note*]
|
| 632 |
+
|
| 633 |
+
Access checking is performed as if in a context unrelated to `T` and any
|
| 634 |
+
of the `Args`. Only the validity of the immediate context of the
|
| 635 |
+
variable initialization is considered.
|
| 636 |
+
|
| 637 |
+
[*Note 3*: The evaluation of the initialization can result in side
|
| 638 |
+
effects such as the instantiation of class template specializations and
|
| 639 |
+
function template specializations, the generation of implicitly-defined
|
| 640 |
+
functions, and so on. Such side effects are not in the “immediate
|
| 641 |
+
context” and can result in the program being ill-formed. — *end note*]
|
| 642 |
+
|
| 643 |
+
The predicate condition for a template specialization
|
| 644 |
+
`has_unique_object_representations<T>` shall be satisfied if and only
|
| 645 |
+
if:
|
| 646 |
+
|
| 647 |
+
- `T` is trivially copyable, and
|
| 648 |
+
- any two objects of type `T` with the same value have the same object
|
| 649 |
+
representation, where two objects of array or non-union class type are
|
| 650 |
+
considered to have the same value if their respective sequences of
|
| 651 |
+
direct subobjects have the same values, and two objects of union type
|
| 652 |
+
are considered to have the same value if they have the same active
|
| 653 |
+
member and the corresponding members have the same value.
|
| 654 |
+
|
| 655 |
+
The set of scalar types for which this condition holds is
|
| 656 |
+
*implementation-defined*.
|
| 657 |
+
|
| 658 |
+
[*Note 4*: If a type has padding bits, the condition does not hold;
|
| 659 |
+
otherwise, the condition holds true for integral types. — *end note*]
|
| 660 |
+
|
| 661 |
+
### Type property queries <a id="meta.unary.prop.query">[[meta.unary.prop.query]]</a>
|
| 662 |
+
|
| 663 |
+
This subclause contains templates that may be used to query properties
|
| 664 |
+
of types at compile time.
|
| 665 |
+
|
| 666 |
+
Each of these templates shall be a *Cpp17UnaryTypeTrait* [[meta.rqmts]]
|
| 667 |
+
with a base characteristic of `integral_constant<size_t, Value>`.
|
| 668 |
+
|
| 669 |
+
[*Example 1*:
|
| 670 |
+
|
| 671 |
+
``` cpp
|
| 672 |
+
// the following assertions hold:
|
| 673 |
+
assert(rank_v<int> == 0);
|
| 674 |
+
assert(rank_v<int[2]> == 1);
|
| 675 |
+
assert(rank_v<int[][4]> == 2);
|
| 676 |
+
```
|
| 677 |
+
|
| 678 |
+
— *end example*]
|
| 679 |
+
|
| 680 |
+
[*Example 2*:
|
| 681 |
+
|
| 682 |
+
``` cpp
|
| 683 |
+
// the following assertions hold:
|
| 684 |
+
assert(extent_v<int> == 0);
|
| 685 |
+
assert(extent_v<int[2]> == 2);
|
| 686 |
+
assert(extent_v<int[2][4]> == 2);
|
| 687 |
+
assert(extent_v<int[][4]> == 0);
|
| 688 |
+
assert((extent_v<int, 1>) == 0);
|
| 689 |
+
assert((extent_v<int[2], 1>) == 0);
|
| 690 |
+
assert((extent_v<int[2][4], 1>) == 4);
|
| 691 |
+
assert((extent_v<int[][4], 1>) == 4);
|
| 692 |
+
```
|
| 693 |
+
|
| 694 |
+
— *end example*]
|
| 695 |
+
|
| 696 |
+
### Relationships between types <a id="meta.rel">[[meta.rel]]</a>
|
| 697 |
+
|
| 698 |
+
This subclause contains templates that may be used to query
|
| 699 |
+
relationships between types at compile time.
|
| 700 |
+
|
| 701 |
+
Each of these templates shall be a *Cpp17BinaryTypeTrait* [[meta.rqmts]]
|
| 702 |
+
with a base characteristic of `true_type` if the corresponding condition
|
| 703 |
+
is true, otherwise `false_type`.
|
| 704 |
+
|
| 705 |
+
For the purpose of defining the templates in this subclause, a function
|
| 706 |
+
call expression `declval<T>()` for any type `T` is considered to be a
|
| 707 |
+
trivial [[term.trivial.type]], [[special]] function call that is not an
|
| 708 |
+
odr-use [[term.odr.use]] of `declval` in the context of the
|
| 709 |
+
corresponding definition notwithstanding the restrictions of
|
| 710 |
+
[[declval]].
|
| 711 |
+
|
| 712 |
+
[*Example 1*:
|
| 713 |
+
|
| 714 |
+
``` cpp
|
| 715 |
+
struct B {};
|
| 716 |
+
struct B1 : B {};
|
| 717 |
+
struct B2 : B {};
|
| 718 |
+
struct D : private B1, private B2 {};
|
| 719 |
+
|
| 720 |
+
is_base_of_v<B, D> // true
|
| 721 |
+
is_base_of_v<const B, D> // true
|
| 722 |
+
is_base_of_v<B, const D> // true
|
| 723 |
+
is_base_of_v<B, const B> // true
|
| 724 |
+
is_base_of_v<D, B> // false
|
| 725 |
+
is_base_of_v<B&, D&> // false
|
| 726 |
+
is_base_of_v<B[3], D[3]> // false
|
| 727 |
+
is_base_of_v<int, int> // false
|
| 728 |
+
```
|
| 729 |
+
|
| 730 |
+
— *end example*]
|
| 731 |
+
|
| 732 |
+
The predicate condition for a template specialization
|
| 733 |
+
`is_convertible<From, To>` shall be satisfied if and only if the return
|
| 734 |
+
expression in the following code would be well-formed, including any
|
| 735 |
+
implicit conversions to the return type of the function:
|
| 736 |
+
|
| 737 |
+
``` cpp
|
| 738 |
+
To test() {
|
| 739 |
+
return declval<From>();
|
| 740 |
+
}
|
| 741 |
+
```
|
| 742 |
+
|
| 743 |
+
[*Note 1*: This requirement gives well-defined results for reference
|
| 744 |
+
types, array types, function types, and cv `void`. — *end note*]
|
| 745 |
+
|
| 746 |
+
Access checking is performed in a context unrelated to `To` and `From`.
|
| 747 |
+
Only the validity of the immediate context of the *expression* of the
|
| 748 |
+
`return` statement [[stmt.return]] (including initialization of the
|
| 749 |
+
returned object or reference) is considered.
|
| 750 |
+
|
| 751 |
+
[*Note 2*: The initialization can result in side effects such as the
|
| 752 |
+
instantiation of class template specializations and function template
|
| 753 |
+
specializations, the generation of implicitly-defined functions, and so
|
| 754 |
+
on. Such side effects are not in the “immediate context” and can result
|
| 755 |
+
in the program being ill-formed. — *end note*]
|
| 756 |
+
|
| 757 |
+
### Transformations between types <a id="meta.trans">[[meta.trans]]</a>
|
| 758 |
+
|
| 759 |
+
#### General <a id="meta.trans.general">[[meta.trans.general]]</a>
|
| 760 |
+
|
| 761 |
+
Subclause [[meta.trans]] contains templates that may be used to
|
| 762 |
+
transform one type to another following some predefined rule.
|
| 763 |
+
|
| 764 |
+
Each of the templates in [[meta.trans]] shall be a
|
| 765 |
+
*Cpp17TransformationTrait* [[meta.rqmts]].
|
| 766 |
+
|
| 767 |
+
#### Const-volatile modifications <a id="meta.trans.cv">[[meta.trans.cv]]</a>
|
| 768 |
+
|
| 769 |
+
#### Reference modifications <a id="meta.trans.ref">[[meta.trans.ref]]</a>
|
| 770 |
+
|
| 771 |
+
#### Sign modifications <a id="meta.trans.sign">[[meta.trans.sign]]</a>
|
| 772 |
+
|
| 773 |
+
#### Array modifications <a id="meta.trans.arr">[[meta.trans.arr]]</a>
|
| 774 |
+
|
| 775 |
+
[*Example 1*:
|
| 776 |
+
|
| 777 |
+
``` cpp
|
| 778 |
+
// the following assertions hold:
|
| 779 |
+
assert((is_same_v<remove_extent_t<int>, int>));
|
| 780 |
+
assert((is_same_v<remove_extent_t<int[2]>, int>));
|
| 781 |
+
assert((is_same_v<remove_extent_t<int[2][3]>, int[3]>));
|
| 782 |
+
assert((is_same_v<remove_extent_t<int[][3]>, int[3]>));
|
| 783 |
+
```
|
| 784 |
+
|
| 785 |
+
— *end example*]
|
| 786 |
+
|
| 787 |
+
[*Example 2*:
|
| 788 |
+
|
| 789 |
+
``` cpp
|
| 790 |
+
// the following assertions hold:
|
| 791 |
+
assert((is_same_v<remove_all_extents_t<int>, int>));
|
| 792 |
+
assert((is_same_v<remove_all_extents_t<int[2]>, int>));
|
| 793 |
+
assert((is_same_v<remove_all_extents_t<int[2][3]>, int>));
|
| 794 |
+
assert((is_same_v<remove_all_extents_t<int[][3]>, int>));
|
| 795 |
+
```
|
| 796 |
+
|
| 797 |
+
— *end example*]
|
| 798 |
+
|
| 799 |
+
#### Pointer modifications <a id="meta.trans.ptr">[[meta.trans.ptr]]</a>
|
| 800 |
+
|
| 801 |
+
#### Other transformations <a id="meta.trans.other">[[meta.trans.other]]</a>
|
| 802 |
+
|
| 803 |
+
[*Note 1*: The compilation of the expression can result in side effects
|
| 804 |
+
such as the instantiation of class template specializations and function
|
| 805 |
+
template specializations, the generation of implicitly-defined
|
| 806 |
+
functions, and so on. Such side effects are not in the “immediate
|
| 807 |
+
context” and can result in the program being ill-formed. — *end note*]
|
| 808 |
+
|
| 809 |
+
In addition to being available via inclusion of the `<type_traits>`
|
| 810 |
+
header, the templates `unwrap_reference`, `unwrap_ref_decay`,
|
| 811 |
+
`unwrap_reference_t`, and `unwrap_ref_decay_t` are available when the
|
| 812 |
+
header `<functional>` [[functional.syn]] is included.
|
| 813 |
+
|
| 814 |
+
Let:
|
| 815 |
+
|
| 816 |
+
- `CREF(A)` be `add_lvalue_reference_t<const remove_reference_t<A>{}>`,
|
| 817 |
+
- `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes
|
| 818 |
+
the same type as `U` with the addition of `A`’s cv and reference
|
| 819 |
+
qualifiers, for a non-reference cv-unqualified type `U`,
|
| 820 |
+
- `COPYCV(FROM, TO)` be an alias for type `TO` with the addition of
|
| 821 |
+
`FROM`’s top-level cv-qualifiers,
|
| 822 |
+
\[*Example 1*: `COPYCV(const int, volatile short)` is an alias for
|
| 823 |
+
`const volatile short`. — *end example*]
|
| 824 |
+
- `COND-RES(X, Y)` be
|
| 825 |
+
`decltype(false ? declval<X(&)()>()() : declval<Y(&)()>()())`.
|
| 826 |
+
|
| 827 |
+
Given types `A` and `B`, let `X` be `remove_reference_t<A>`, let `Y` be
|
| 828 |
+
`remove_reference_t<B>`, and let `COMMON-{REF}(A, B)` be:
|
| 829 |
+
|
| 830 |
+
- If `A` and `B` are both lvalue reference types, `COMMON-REF(A, B)` is
|
| 831 |
+
`COND-RES(COPYCV(X, Y) &,
|
| 832 |
+
COPYCV({}Y, X) &)` if that type exists and is a reference type.
|
| 833 |
+
- Otherwise, let `C` be `remove_reference_t<COMMON-REF(X&, Y&)>&&`. If
|
| 834 |
+
`A` and `B` are both rvalue reference types, `C` is well-formed, and
|
| 835 |
+
`is_convertible_v<A, C> && is_convertible_v<B, C>` is `true`, then
|
| 836 |
+
`COMMON-REF(A, B)` is `C`.
|
| 837 |
+
- Otherwise, let `D` be `COMMON-REF(const X&, Y&)`. If `A` is an rvalue
|
| 838 |
+
reference and `B` is an lvalue reference and `D` is well-formed and
|
| 839 |
+
`is_convertible_v<A, D>` is `true`, then `COMMON-REF(A, B)` is `D`.
|
| 840 |
+
- Otherwise, if `A` is an lvalue reference and `B` is an rvalue
|
| 841 |
+
reference, then `COMMON-REF(A, B)` is `COMMON-REF(B, A)`.
|
| 842 |
+
- Otherwise, `COMMON-REF(A, B)` is ill-formed.
|
| 843 |
+
|
| 844 |
+
If any of the types computed above is ill-formed, then
|
| 845 |
+
`COMMON-REF(A, B)` is ill-formed.
|
| 846 |
+
|
| 847 |
+
Note A: For the `common_type` trait applied to a template parameter pack
|
| 848 |
+
`T` of types, the member `type` shall be either defined or not present
|
| 849 |
+
as follows:
|
| 850 |
+
|
| 851 |
+
- If `sizeof...(T)` is zero, there shall be no member `type`.
|
| 852 |
+
- If `sizeof...(T)` is one, let `T0` denote the sole type constituting
|
| 853 |
+
the pack `T`. The member *typedef-name* `type` shall denote the same
|
| 854 |
+
type, if any, as `common_type_t<T0, T0>`; otherwise there shall be no
|
| 855 |
+
member `type`.
|
| 856 |
+
- If `sizeof...(T)` is two, let the first and second types constituting
|
| 857 |
+
`T` be denoted by `T1` and `T2`, respectively, and let `D1` and `D2`
|
| 858 |
+
denote the same types as `decay_t<T1>` and `decay_t<T2>`,
|
| 859 |
+
respectively.
|
| 860 |
+
- If `is_same_v<T1, D1>` is `false` or `is_same_v<T2, D2>` is `false`,
|
| 861 |
+
let `C` denote the same type, if any, as `common_type_t<D1, D2>`.
|
| 862 |
+
- \[*Note 2*: None of the following will apply if there is a
|
| 863 |
+
specialization `common_type<D1, D2>`. — *end note*]
|
| 864 |
+
- Otherwise, if
|
| 865 |
+
``` cpp
|
| 866 |
+
decay_t<decltype(false ? declval<D1>() : declval<D2>())>
|
| 867 |
+
```
|
| 868 |
+
|
| 869 |
+
denotes a valid type, let `C` denote that type.
|
| 870 |
+
- Otherwise, if `COND-RES(CREF(D1),
|
| 871 |
+
CREF(D2))` denotes a type, let `C` denote the type
|
| 872 |
+
`decay_t<COND-RES(CREF(D1),
|
| 873 |
+
CREF(D2))>`.
|
| 874 |
+
|
| 875 |
+
In either case, the member *typedef-name* `type` shall denote the same
|
| 876 |
+
type, if any, as `C`. Otherwise, there shall be no member `type`.
|
| 877 |
+
- If `sizeof...(T)` is greater than two, let `T1`, `T2`, and `R`,
|
| 878 |
+
respectively, denote the first, second, and (pack of) remaining types
|
| 879 |
+
constituting `T`. Let `C` denote the same type, if any, as
|
| 880 |
+
`common_type_t<T1, T2>`. If there is such a type `C`, the member
|
| 881 |
+
*typedef-name* `type` shall denote the same type, if any, as
|
| 882 |
+
`common_type_t<C, R...>`. Otherwise, there shall be no member `type`.
|
| 883 |
+
|
| 884 |
+
Note B: Notwithstanding the provisions of [[meta.type.synop]], and
|
| 885 |
+
pursuant to [[namespace.std]], a program may specialize
|
| 886 |
+
`common_type<T1, T2>` for types `T1` and `T2` such that
|
| 887 |
+
`is_same_v<T1, decay_t<T1>>` and `is_same_v<T2, decay_t<T2>>` are each
|
| 888 |
+
`true`.
|
| 889 |
+
|
| 890 |
+
[*Note 3*: Such specializations are needed when only explicit
|
| 891 |
+
conversions are desired between the template arguments. — *end note*]
|
| 892 |
+
|
| 893 |
+
Such a specialization need not have a member named `type`, but if it
|
| 894 |
+
does, the *qualified-id* `common_type<T1, T2>::type` shall denote a
|
| 895 |
+
cv-unqualified non-reference type to which each of the types `T1` and
|
| 896 |
+
`T2` is explicitly convertible. Moreover, `common_type_t<T1, T2>` shall
|
| 897 |
+
denote the same type, if any, as does `common_type_t<T2, T1>`. No
|
| 898 |
+
diagnostic is required for a violation of this Note’s rules.
|
| 899 |
+
|
| 900 |
+
Note C: For the `common_reference` trait applied to a parameter pack `T`
|
| 901 |
+
of types, the member `type` shall be either defined or not present as
|
| 902 |
+
follows:
|
| 903 |
+
|
| 904 |
+
- If `sizeof...(T)` is zero, there shall be no member `type`.
|
| 905 |
+
- Otherwise, if `sizeof...(T)` is one, let `T0` denote the sole type in
|
| 906 |
+
the pack `T`. The member typedef `type` shall denote the same type as
|
| 907 |
+
`T0`.
|
| 908 |
+
- Otherwise, if `sizeof...(T)` is two, let `T1` and `T2` denote the two
|
| 909 |
+
types in the pack `T`. Then
|
| 910 |
+
- Let `R` be `COMMON-REF(T1, T2)`. If `T1` and `T2` are reference
|
| 911 |
+
types, `R` is well-formed, and
|
| 912 |
+
`is_convertible_v<add_pointer_t<T1>, add_pointer_t<R>> && is_convertible_v<add_poin{}ter_t<T2>, add_pointer_t<R>>`
|
| 913 |
+
is `true`, then the member typedef `type` denotes `R`.
|
| 914 |
+
- Otherwise, if
|
| 915 |
+
`basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>,
|
| 916 |
+
{}XREF({}T1), XREF(T2)>::type` is well-formed, then the member
|
| 917 |
+
typedef `type` denotes that type.
|
| 918 |
+
- Otherwise, if `COND-RES(T1, T2)` is well-formed, then the member
|
| 919 |
+
typedef `type` denotes that type.
|
| 920 |
+
- Otherwise, if `common_type_t<T1, T2>` is well-formed, then the
|
| 921 |
+
member typedef `type` denotes that type.
|
| 922 |
+
- Otherwise, there shall be no member `type`.
|
| 923 |
+
- Otherwise, if `sizeof...(T)` is greater than two, let `T1`, `T2`, and
|
| 924 |
+
`Rest`, respectively, denote the first, second, and (pack of)
|
| 925 |
+
remaining types comprising `T`. Let `C` be the type
|
| 926 |
+
`common_reference_t<T1, T2>`. Then:
|
| 927 |
+
- If there is such a type `C`, the member typedef `type` shall denote
|
| 928 |
+
the same type, if any, as `common_reference_t<C, Rest...>`.
|
| 929 |
+
- Otherwise, there shall be no member `type`.
|
| 930 |
+
|
| 931 |
+
Note D: Notwithstanding the provisions of [[meta.type.synop]], and
|
| 932 |
+
pursuant to [[namespace.std]], a program may partially specialize
|
| 933 |
+
`basic_common_reference<T, U, TQual, UQual>` for types `T` and `U` such
|
| 934 |
+
that `is_same_v<T, decay_t<T>>` and `is_same_v<U, decay_t<U>>` are each
|
| 935 |
+
`true`.
|
| 936 |
+
|
| 937 |
+
[*Note 4*: Such specializations can be used to influence the result of
|
| 938 |
+
`common_reference`, and are needed when only explicit conversions are
|
| 939 |
+
desired between the template arguments. — *end note*]
|
| 940 |
+
|
| 941 |
+
Such a specialization need not have a member named `type`, but if it
|
| 942 |
+
does, the *qualified-id*
|
| 943 |
+
`basic_common_reference<T, U, TQual, UQual>::type` shall denote a type
|
| 944 |
+
to which each of the types `TQual<T>` and `UQual<U>` is convertible.
|
| 945 |
+
Moreover, `basic_common_reference<T, U, TQual, UQual>::type` shall
|
| 946 |
+
denote the same type, if any, as does
|
| 947 |
+
`basic_common_reference<U, T, UQual, TQual>::type`. No diagnostic is
|
| 948 |
+
required for a violation of these rules.
|
| 949 |
+
|
| 950 |
+
[*Example 2*:
|
| 951 |
+
|
| 952 |
+
Given these definitions:
|
| 953 |
+
|
| 954 |
+
``` cpp
|
| 955 |
+
using PF1 = bool (&)();
|
| 956 |
+
using PF2 = short (*)(long);
|
| 957 |
+
|
| 958 |
+
struct S {
|
| 959 |
+
operator PF2() const;
|
| 960 |
+
double operator()(char, int&);
|
| 961 |
+
void fn(long) const;
|
| 962 |
+
char data;
|
| 963 |
+
};
|
| 964 |
+
|
| 965 |
+
using PMF = void (S::*)(long) const;
|
| 966 |
+
using PMD = char S::*;
|
| 967 |
+
```
|
| 968 |
+
|
| 969 |
+
the following assertions will hold:
|
| 970 |
+
|
| 971 |
+
``` cpp
|
| 972 |
+
static_assert(is_same_v<invoke_result_t<S, int>, short>);
|
| 973 |
+
static_assert(is_same_v<invoke_result_t<S&, unsigned char, int&>, double>);
|
| 974 |
+
static_assert(is_same_v<invoke_result_t<PF1>, bool>);
|
| 975 |
+
static_assert(is_same_v<invoke_result_t<PMF, unique_ptr<S>, int>, void>);
|
| 976 |
+
static_assert(is_same_v<invoke_result_t<PMD, S>, char&&>);
|
| 977 |
+
static_assert(is_same_v<invoke_result_t<PMD, const S*>, const char&>);
|
| 978 |
+
```
|
| 979 |
+
|
| 980 |
+
— *end example*]
|
| 981 |
+
|
| 982 |
+
### Logical operator traits <a id="meta.logical">[[meta.logical]]</a>
|
| 983 |
+
|
| 984 |
+
This subclause describes type traits for applying logical operators to
|
| 985 |
+
other type traits.
|
| 986 |
+
|
| 987 |
+
``` cpp
|
| 988 |
+
template<class... B> struct conjunction : see below { };
|
| 989 |
+
```
|
| 990 |
+
|
| 991 |
+
The class template `conjunction` forms the logical conjunction of its
|
| 992 |
+
template type arguments.
|
| 993 |
+
|
| 994 |
+
For a specialization `conjunction<``B₁``, `…`, ``B_N``>`, if there is a
|
| 995 |
+
template type argument `Bᵢ` for which `bool(``Bᵢ``::value)` is `false`,
|
| 996 |
+
then instantiating `conjunction<``B₁``, `…`, ``B_N``>::value` does not
|
| 997 |
+
require the instantiation of `Bⱼ``::value` for j > i.
|
| 998 |
+
|
| 999 |
+
[*Note 1*: This is analogous to the short-circuiting behavior of the
|
| 1000 |
+
built-in operator `&&`. — *end note*]
|
| 1001 |
+
|
| 1002 |
+
Every template type argument for which `Bᵢ``::value` is instantiated
|
| 1003 |
+
shall be usable as a base class and shall have a member `value` which is
|
| 1004 |
+
convertible to `bool`, is not hidden, and is unambiguously available in
|
| 1005 |
+
the type.
|
| 1006 |
+
|
| 1007 |
+
The specialization `conjunction<``B₁``, `…`, ``B_N``>` has a public and
|
| 1008 |
+
unambiguous base that is either
|
| 1009 |
+
|
| 1010 |
+
- the first type `Bᵢ` in the list `true_type, ``B₁``, `…`, ``B_N` for
|
| 1011 |
+
which `bool(``Bᵢ``::value)` is `false`, or
|
| 1012 |
+
- if there is no such `Bᵢ`, the last type in the list.
|
| 1013 |
+
|
| 1014 |
+
[*Note 2*: This means a specialization of `conjunction` does not
|
| 1015 |
+
necessarily inherit from either `true_type` or
|
| 1016 |
+
`false_type`. — *end note*]
|
| 1017 |
+
|
| 1018 |
+
The member names of the base class, other than `conjunction` and
|
| 1019 |
+
`operator=`, shall not be hidden and shall be unambiguously available in
|
| 1020 |
+
`conjunction`.
|
| 1021 |
+
|
| 1022 |
+
``` cpp
|
| 1023 |
+
template<class... B> struct disjunction : see below { };
|
| 1024 |
+
```
|
| 1025 |
+
|
| 1026 |
+
The class template `disjunction` forms the logical disjunction of its
|
| 1027 |
+
template type arguments.
|
| 1028 |
+
|
| 1029 |
+
For a specialization `disjunction<``B₁``, `…`, ``B_N``>`, if there is a
|
| 1030 |
+
template type argument `Bᵢ` for which `bool(``Bᵢ``::value)` is `true`,
|
| 1031 |
+
then instantiating `disjunction<``B₁``, `…`, ``B_N``>::value` does not
|
| 1032 |
+
require the instantiation of `Bⱼ``::value` for j > i.
|
| 1033 |
+
|
| 1034 |
+
[*Note 3*: This is analogous to the short-circuiting behavior of the
|
| 1035 |
+
built-in operator `||`. — *end note*]
|
| 1036 |
+
|
| 1037 |
+
Every template type argument for which `Bᵢ``::value` is instantiated
|
| 1038 |
+
shall be usable as a base class and shall have a member `value` which is
|
| 1039 |
+
convertible to `bool`, is not hidden, and is unambiguously available in
|
| 1040 |
+
the type.
|
| 1041 |
+
|
| 1042 |
+
The specialization `disjunction<``B₁``, `…`, ``B_N``>` has a public and
|
| 1043 |
+
unambiguous base that is either
|
| 1044 |
+
|
| 1045 |
+
- the first type `Bᵢ` in the list `false_type, ``B₁``, `…`, ``B_N` for
|
| 1046 |
+
which `bool(``Bᵢ``::value)` is `true`, or
|
| 1047 |
+
- if there is no such `Bᵢ`, the last type in the list.
|
| 1048 |
+
|
| 1049 |
+
[*Note 4*: This means a specialization of `disjunction` does not
|
| 1050 |
+
necessarily inherit from either `true_type` or
|
| 1051 |
+
`false_type`. — *end note*]
|
| 1052 |
+
|
| 1053 |
+
The member names of the base class, other than `disjunction` and
|
| 1054 |
+
`operator=`, shall not be hidden and shall be unambiguously available in
|
| 1055 |
+
`disjunction`.
|
| 1056 |
+
|
| 1057 |
+
``` cpp
|
| 1058 |
+
template<class B> struct negation : see below { };
|
| 1059 |
+
```
|
| 1060 |
+
|
| 1061 |
+
The class template `negation` forms the logical negation of its template
|
| 1062 |
+
type argument. The type `negation<B>` is a *Cpp17UnaryTypeTrait* with a
|
| 1063 |
+
base characteristic of `bool_constant<!bool(B::value)>`.
|
| 1064 |
+
|
| 1065 |
+
### Member relationships <a id="meta.member">[[meta.member]]</a>
|
| 1066 |
+
|
| 1067 |
+
``` cpp
|
| 1068 |
+
template<class S, class M>
|
| 1069 |
+
constexpr bool is_pointer_interconvertible_with_class(M S::*m) noexcept;
|
| 1070 |
+
```
|
| 1071 |
+
|
| 1072 |
+
*Mandates:* `S` is a complete type.
|
| 1073 |
+
|
| 1074 |
+
*Returns:* `true` if and only if `S` is a standard-layout type, `M` is
|
| 1075 |
+
an object type, `m` is not null, and each object `s` of type `S` is
|
| 1076 |
+
pointer-interconvertible [[basic.compound]] with its subobject `s.*m`.
|
| 1077 |
+
|
| 1078 |
+
``` cpp
|
| 1079 |
+
template<class S1, class S2, class M1, class M2>
|
| 1080 |
+
constexpr bool is_corresponding_member(M1 S1::*m1, M2 S2::*m2) noexcept;
|
| 1081 |
+
```
|
| 1082 |
+
|
| 1083 |
+
*Mandates:* `S1` and `S2` are complete types.
|
| 1084 |
+
|
| 1085 |
+
*Returns:* `true` if and only if `S1` and `S2` are standard-layout
|
| 1086 |
+
struct [[class.prop]] types, `M1` and `M2` are object types, `m1` and
|
| 1087 |
+
`m2` are not null, and `m1` and `m2` point to corresponding members of
|
| 1088 |
+
the common initial sequence [[class.mem]] of `S1` and `S2`.
|
| 1089 |
+
|
| 1090 |
+
[*Note 1*:
|
| 1091 |
+
|
| 1092 |
+
The type of a pointer-to-member expression `&C::b` is not always a
|
| 1093 |
+
pointer to member of `C`, leading to potentially surprising results when
|
| 1094 |
+
using these functions in conjunction with inheritance.
|
| 1095 |
+
|
| 1096 |
+
[*Example 1*:
|
| 1097 |
+
|
| 1098 |
+
``` cpp
|
| 1099 |
+
struct A { int a; }; // a standard-layout class
|
| 1100 |
+
struct B { int b; }; // a standard-layout class
|
| 1101 |
+
struct C: public A, public B { }; // not a standard-layout class
|
| 1102 |
+
|
| 1103 |
+
static_assert( is_pointer_interconvertible_with_class( &C::b ) );
|
| 1104 |
+
// Succeeds because, despite its appearance, &C::b has type
|
| 1105 |
+
// ``pointer to member of B of type int''.
|
| 1106 |
+
static_assert( is_pointer_interconvertible_with_class<C>( &C::b ) );
|
| 1107 |
+
// Forces the use of class C, and fails.
|
| 1108 |
+
|
| 1109 |
+
static_assert( is_corresponding_member( &C::a, &C::b ) );
|
| 1110 |
+
// Succeeds because, despite its appearance, &C::a and &C::b have types
|
| 1111 |
+
// ``pointer to member of A of type int'' and
|
| 1112 |
+
// ``pointer to member of B of type int'', respectively.
|
| 1113 |
+
static_assert( is_corresponding_member<C, C>( &C::a, &C::b ) );
|
| 1114 |
+
// Forces the use of class C, and fails.
|
| 1115 |
+
```
|
| 1116 |
+
|
| 1117 |
+
— *end example*]
|
| 1118 |
+
|
| 1119 |
+
— *end note*]
|
| 1120 |
+
|
| 1121 |
+
### Constant evaluation context <a id="meta.const.eval">[[meta.const.eval]]</a>
|
| 1122 |
+
|
| 1123 |
+
``` cpp
|
| 1124 |
+
constexpr bool is_constant_evaluated() noexcept;
|
| 1125 |
+
```
|
| 1126 |
+
|
| 1127 |
+
*Effects:* Equivalent to:
|
| 1128 |
+
|
| 1129 |
+
``` cpp
|
| 1130 |
+
if consteval {
|
| 1131 |
+
return true;
|
| 1132 |
+
} else {
|
| 1133 |
+
return false;
|
| 1134 |
+
}
|
| 1135 |
+
```
|
| 1136 |
+
|
| 1137 |
+
[*Example 1*:
|
| 1138 |
+
|
| 1139 |
+
``` cpp
|
| 1140 |
+
constexpr void f(unsigned char *p, int n) {
|
| 1141 |
+
if (std::is_constant_evaluated()) { // should not be a constexpr if statement
|
| 1142 |
+
for (int k = 0; k<n; ++k) p[k] = 0;
|
| 1143 |
+
} else {
|
| 1144 |
+
memset(p, 0, n); // not a core constant expression
|
| 1145 |
+
}
|
| 1146 |
+
}
|
| 1147 |
+
```
|
| 1148 |
+
|
| 1149 |
+
— *end example*]
|
| 1150 |
+
|