/* Copyright (C) 2015 Povilas Kanapickas This file is part of cppreference-doc This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. */ #ifndef CPPREFERENCE_TYPE_TRAITS_H #define CPPREFERENCE_TYPE_TRAITS_H #if CPPREFERENCE_STDVER>= 2011 #include // for size_t namespace std { template struct integral_constant { typedef T value_type; typedef integral_constant type; static constexpr T value = v; constexpr operator value_type() const; constexpr T operator()() const; }; typedef integral_constant false_type; typedef integral_constant true_type; #if CPPREFERENCE_STDVER >= 2017 template using bool_constant = integral_constant; #endif // SIMPLIFIED: the actual base type depends on T // primary type categories template struct is_void : integral_constant {}; #if CPPREFERENCE_STDVER>= 2014 template struct is_null_pointer : integral_constant {}; #endif template struct is_integral : integral_constant {}; template struct is_floating_point : integral_constant {}; template struct is_array : integral_constant {}; template struct is_enum : integral_constant {}; template struct is_union : integral_constant {}; template struct is_class : integral_constant {}; template struct is_function : integral_constant {}; template struct is_pointer : integral_constant {}; template struct is_lvalue_reference : integral_constant {}; template struct is_rvalue_reference : integral_constant {}; template struct is_member_object_pointer : integral_constant {}; template struct is_member_function_pointer : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_void_v = false; template inline constexpr bool is_null_pointer_v = false; template inline constexpr bool is_integral_v = false; template inline constexpr bool is_floating_point_v = false; template inline constexpr bool is_array_v = false; template inline constexpr bool is_enum_v = false; template inline constexpr bool is_union_v = false; template inline constexpr bool is_class_v = false; template inline constexpr bool is_function_v = false; template inline constexpr bool is_pointer_v = false; template inline constexpr bool is_lvalue_reference_v = false; template inline constexpr bool is_rvalue_reference_v = false; template inline constexpr bool is_member_object_pointer_v = false; template inline constexpr bool is_member_function_pointer_v = false; #endif // composite type categories template struct is_fundamental : integral_constant {}; template struct is_arithmetic : integral_constant {}; template struct is_scalar : integral_constant {}; template struct is_object : integral_constant {}; template struct is_compound : integral_constant {}; template struct is_reference : integral_constant {}; template struct is_member_pointer : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_fundamental_v = false; template inline constexpr bool is_arithmetic_v = false; template inline constexpr bool is_scalar_v = false; template inline constexpr bool is_object_v = false; template inline constexpr bool is_compound_v = false; template inline constexpr bool is_reference_v = false; template inline constexpr bool is_member_pointer_v = false; #endif // type properties template struct is_const : integral_constant {}; template struct is_volatile : integral_constant {}; template struct is_trivial : integral_constant {}; template struct is_trivially_copyable : integral_constant {}; template struct is_standard_layout : integral_constant {}; template struct is_pod : integral_constant {}; template struct is_literal_type : integral_constant {}; template struct is_empty : integral_constant {}; template struct is_polymorphic : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template struct is_final : integral_constant {}; #endif template struct is_abstract : integral_constant {}; template struct is_signed : integral_constant {}; template struct is_unsigned : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_const_v = false; template inline constexpr bool is_volatile_v = false; template inline constexpr bool is_trivial_v = false; template inline constexpr bool is_trivially_copyable_v = false; template inline constexpr bool is_standard_layout_v = false; template inline constexpr bool is_pod_v = false; template inline constexpr bool is_literal_type_v = false; template inline constexpr bool is_empty_v = false; template inline constexpr bool is_polymorphic_v = false; template inline constexpr bool is_final_v = false; template inline constexpr bool is_abstract_v = false; template inline constexpr bool is_signed_v = false; template inline constexpr bool is_unsigned_v = false; #endif // supported operations template struct is_constructible : integral_constant {}; template struct is_trivially_constructible : integral_constant {}; template struct is_nothrow_constructible : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_constructible_v = false; template inline constexpr bool is_trivially_constructible_v = false; template inline constexpr bool is_nothrow_constructible_v = false; #endif template struct is_default_constructible : integral_constant {}; template struct is_trivially_default_constructible : integral_constant {}; template struct is_nothrow_default_constructible : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_default_constructible_v = false; template inline constexpr bool is_trivially_default_constructible_v = false; template inline constexpr bool is_nothrow_default_constructible_v = false; #endif template struct is_copy_constructible : integral_constant {}; template struct is_trivially_copy_constructible : integral_constant {}; template struct is_nothrow_copy_constructible : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_copy_constructible_v = false; template inline constexpr bool is_trivially_copy_constructible_v = false; template inline constexpr bool is_nothrow_copy_constructible_v = false; #endif template struct is_move_constructible : integral_constant {}; template struct is_trivially_move_constructible : integral_constant {}; template struct is_nothrow_move_constructible : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_move_constructible_v = false; template inline constexpr bool is_trivially_move_constructible_v = false; template inline constexpr bool is_nothrow_move_constructible_v = false; #endif template struct is_assignable : integral_constant {}; template struct is_trivially_assignable : integral_constant {}; template struct is_nothrow_assignable : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_assignable_v = false; template inline constexpr bool is_trivially_assignable_v = false; template inline constexpr bool is_nothrow_assignable_v = false; #endif template struct is_copy_assignable : integral_constant {}; template struct is_trivially_copy_assignable : integral_constant {}; template struct is_nothrow_copy_assignable : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_copy_assignable_v = false; template inline constexpr bool is_trivially_copy_assignable_v = false; template inline constexpr bool is_nothrow_copy_assignable_v = false; #endif template struct is_move_assignable : integral_constant {}; template struct is_trivially_move_assignable : integral_constant {}; template struct is_nothrow_move_assignable : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_move_assignable_v = false; template inline constexpr bool is_trivially_move_assignable_v = false; template inline constexpr bool is_nothrow_move_assignable_v = false; #endif template struct is_destructible : integral_constant {}; template struct is_trivially_destructible : integral_constant {}; template struct is_nothrow_destructible : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_destructible_v = false; template inline constexpr bool is_trivially_destructible_v = false; template inline constexpr bool is_nothrow_destructible_v = false; #endif template struct has_virtual_destructor : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool has_virtual_destructor_v = false; #endif // property queries template struct alignment_of : integral_constant {}; template struct rank : integral_constant {}; template struct extent : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr size_t alignment_of_v = 0; template inline constexpr size_t rank_v = 0; template inline constexpr size_t extent_v = 0; #endif // type relationships template struct is_same : integral_constant {}; template struct is_base_of : integral_constant {}; template struct is_convertible : integral_constant {}; #if CPPREFERENCE_STDVER >= 2014 template inline constexpr bool is_same_v = false; template inline constexpr bool is_base_of_v = false; template inline constexpr bool is_convertible_v = false; #endif // const-volatility specifiers template struct remove_cv { typedef T type; // SIMPLIFIED type }; template struct remove_const { typedef T type; // SIMPLIFIED type }; template struct remove_volatile { typedef T type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using remove_cv_t = T; // SIMPLIFIED typedef template using remove_const_t = T; // SIMPLIFIED typedef template using remove_volatile_t = T; // SIMPLIFIED typedef #endif template struct add_cv { typedef T type; // SIMPLIFIED type }; template struct add_const { typedef T type; // SIMPLIFIED type }; template struct add_volatile { typedef T type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using add_cv_t = T; // SIMPLIFIED typedef template using add_const_t = T; // SIMPLIFIED typedef template using add_volatile_t = T; // SIMPLIFIED typedef #endif // references template struct remove_reference { typedef T type; // SIMPLIFIED type }; template struct add_lvalue_reference { typedef T type; // SIMPLIFIED type }; template struct add_rvalue_reference { typedef T type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using remove_reference_t = T; // SIMPLIFIED typedef template using add_lvalue_reference_t = T; // SIMPLIFIED typedef template using add_rvalue_reference_t = T; // SIMPLIFIED typedef #endif // pointers template struct remove_pointer { typedef T type; // SIMPLIFIED type }; template struct add_pointer { typedef T* type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using remove_pointer_t = T; // SIMPLIFIED typedef template using add_pointer_t = T*; // SIMPLIFIED typedef #endif // sign modifiers template struct make_signed { typedef T type; // SIMPLIFIED type }; template struct make_unsigned { typedef T type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using make_signed_t = T; // SIMPLIFIED typedef template using make_unsigned_t = T; // SIMPLIFIED typedef #endif // arrays template struct remove_extent { typedef T type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using remove_extent_t = T; // SIMPLIFIED typedef #endif template struct remove_all_extents { typedef T type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using remove_all_extents_t = T; // SIMPLIFIED typedef #endif // miscellaneous transformations template struct aligned_storage { typedef int type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using aligned_storage_t = int; // SIMPLIFIED typedef #endif template struct aligned_union { typedef int type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using aligned_union_t = int; // SIMPLIFIED typedef #endif template struct decay { typedef T type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using decay_t = T; // SIMPLIFIED typedef #endif #if CPPREFERENCE_SIMPLIFY_TYPEDEFS template struct enable_if { typedef int type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using enable_if_t = int; // SIMPLIFIED typedef #endif #else template struct enable_if {}; template struct enable_if { typedef T type; }; #if CPPREFERENCE_STDVER >= 2014 template using enable_if_t = typename enable_if::type; #endif #endif // CPPREFERENCE_SIMPLIFY_TYPEDEFS template struct conditional { typedef int type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using conditional_t = int; // SIMPLIFIED typedef #endif template struct common_type { typedef int type; }; #if CPPREFERENCE_STDVER >= 2014 template using common_type_t = int; #endif template struct underlying_type { typedef int type; // SIMPLIFIED type }; #if CPPREFERENCE_STDVER >= 2014 template using underlying_type_t = int; // SIMPLIFIED typedef #endif #if CPPREFERENCE_STDVER < 2020 template class result_of { typedef int type; }; // SIMPLIFIED: removed specializations #endif #if CPPREFERENCE_STDVER >= 2014 && CPPREFERENCE_STDVER < 2020 template using result_of_t = int; // SIMPLIFIED typedef #endif #if CPPREFERENCE_STDVER >= 2017 template class invoke_result { typedef int type; }; // SIMPLIFIED: removed specializations template using invoke_result_t = int; // SIMPLIFIED typedef #endif } // namespace std #endif // CPPREFERENCE_STDVER>= 2011 #endif // CPPREFERENCE_TYPE_TRAITS_H