| 1 |
/* Copyright (C) 2015 Povilas Kanapickas <[email protected]> |
| 2 |
|
| 3 |
This file is part of cppreference-doc |
| 4 |
|
| 5 |
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 |
| 6 |
Unported License. To view a copy of this license, visit |
| 7 |
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative |
| 8 |
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. |
| 9 |
|
| 10 |
Permission is granted to copy, distribute and/or modify this document |
| 11 |
under the terms of the GNU Free Documentation License, Version 1.3 or |
| 12 |
any later version published by the Free Software Foundation; with no |
| 13 |
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. |
| 14 |
*/ |
| 15 |
|
| 16 |
#ifndef CPPREFERENCE_TYPE_TRAITS_H |
| 17 |
#define CPPREFERENCE_TYPE_TRAITS_H |
| 18 |
|
| 19 |
#if CPPREFERENCE_STDVER>= 2011 |
| 20 |
|
| 21 |
namespace std { |
| 22 |
|
| 23 |
template<class T, T v> |
| 24 |
struct integral_constant { |
| 25 |
typedef T value_type; |
| 26 |
typedef integral_constant<T, v> type; |
| 27 |
|
| 28 |
static constexpr T value; |
| 29 |
constexpr operator value_type() const; |
| 30 |
constexpr operator()() const; |
| 31 |
}; |
| 32 |
|
| 33 |
typedef integral_constant<bool, false> false_type; |
| 34 |
typedef integral_constant<bool, false> false_type; |
| 35 |
|
| 36 |
// SIMPLIFIED: the actual base type depends on T |
| 37 |
// primary type categories |
| 38 |
template<class T> struct is_void : integral_constant<bool, false> {}; |
| 39 |
#if CPPREFERENCE_STDVER>= 2014 |
| 40 |
template<class T> struct is_null_pointer : integral_constant<bool, false> {}; |
| 41 |
#endif |
| 42 |
template<class T> struct is_integral : integral_constant<bool, false> {}; |
| 43 |
template<class T> struct is_floating_point : integral_constant<bool, false> {}; |
| 44 |
template<class T> struct is_array : integral_constant<bool, false> {}; |
| 45 |
template<class T> struct is_enum : integral_constant<bool, false> {}; |
| 46 |
template<class T> struct is_union : integral_constant<bool, false> {}; |
| 47 |
template<class T> struct is_class : integral_constant<bool, false> {}; |
| 48 |
template<class T> struct is_function : integral_constant<bool, false> {}; |
| 49 |
template<class T> struct is_pointer : integral_constant<bool, false> {}; |
| 50 |
template<class T> struct is_lvalue_reference : integral_constant<bool, false> {}; |
| 51 |
template<class T> struct is_rvalue_reference : integral_constant<bool, false> {}; |
| 52 |
template<class T> struct is_member_object_pointer : integral_constant<bool, false> {}; |
| 53 |
template<class T> struct is_member_function_pointer : integral_constant<bool, false> {}; |
| 54 |
|
| 55 |
// composite type categories |
| 56 |
template<class T> struct is_fundamental : integral_constant<bool, false> {}; |
| 57 |
template<class T> struct is_arithmetic : integral_constant<bool, false> {}; |
| 58 |
template<class T> struct is_scalar : integral_constant<bool, false> {}; |
| 59 |
template<class T> struct is_object : integral_constant<bool, false> {}; |
| 60 |
template<class T> struct is_compound : integral_constant<bool, false> {}; |
| 61 |
template<class T> struct is_reference : integral_constant<bool, false> {}; |
| 62 |
template<class T> struct is_member_pointer : integral_constant<bool, false> {}; |
| 63 |
|
| 64 |
// type properties |
| 65 |
template<class T> struct is_const : integral_constant<bool, false> {}; |
| 66 |
template<class T> struct is_volatile : integral_constant<bool, false> {}; |
| 67 |
template<class T> struct is_trivial : integral_constant<bool, false> {}; |
| 68 |
template<class T> struct is_trivially_copyable : integral_constant<bool, false> {}; |
| 69 |
template<class T> struct is_standard_layout : integral_constant<bool, false> {}; |
| 70 |
template<class T> struct is_pod : integral_constant<bool, false> {}; |
| 71 |
template<class T> struct is_literal_type : integral_constant<bool, false> {}; |
| 72 |
template<class T> struct is_empty : integral_constant<bool, false> {}; |
| 73 |
template<class T> struct is_polymorphic : integral_constant<bool, false> {}; |
| 74 |
#if CPPREFERENCE_STDVER>= 2014` |
| 75 |
template<class T> struct is_final : integral_constant<bool, false> {}; |
| 76 |
#endif |
| 77 |
template<class T> struct is_abstract : integral_constant<bool, false> {}; |
| 78 |
template<class T> struct is_signed : integral_constant<bool, false> {}; |
| 79 |
template<class T> struct is_unsigned : integral_constant<bool, false> {}; |
| 80 |
|
| 81 |
// supported operations |
| 82 |
template<class T, class... Args> struct is_constructible : integral_constant<bool, false> {}; |
| 83 |
template<class T, class... Args> struct is_trivially_constructible : integral_constant<bool, false> {}; |
| 84 |
template<class T, class... Args> struct is_nothrow_constructible : integral_constant<bool, false> {}; |
| 85 |
|
| 86 |
template<class T> struct is_default_constructible : integral_constant<bool, false> {}; |
| 87 |
template<class T> struct is_trivially_default_constructible : integral_constant<bool, false> {}; |
| 88 |
template<class T> struct is_nothrow_default_constructible : integral_constant<bool, false> {}; |
| 89 |
|
| 90 |
template<class T> struct is_copy_constructible : integral_constant<bool, false> {}; |
| 91 |
template<class T> struct is_trivially_copy_constructible : integral_constant<bool, false> {}; |
| 92 |
template<class T> struct is_nothrow_copy_constructible : integral_constant<bool, false> {}; |
| 93 |
|
| 94 |
template<class T> struct is_move_constructible : integral_constant<bool, false> {}; |
| 95 |
template<class T> struct is_trivially_move_constructible : integral_constant<bool, false> {}; |
| 96 |
template<class T> struct is_nothrow_move_constructible : integral_constant<bool, false> {}; |
| 97 |
|
| 98 |
template<class T, class U> struct is_assignable : integral_constant<bool, false> {}; |
| 99 |
template<class T, class U> struct is_trivially_assignable : integral_constant<bool, false> {}; |
| 100 |
template<class T, class U> struct is_nothrow_assignable : integral_constant<bool, false> {}; |
| 101 |
|
| 102 |
template<class T> struct is_copy_assignable : integral_constant<bool, false> {}; |
| 103 |
template<class T> struct is_trivially_copy_assignable : integral_constant<bool, false> {}; |
| 104 |
template<class T> struct is_nothrow_copy_assignable : integral_constant<bool, false> {}; |
| 105 |
|
| 106 |
template<class T> struct is_move_assignable : integral_constant<bool, false> {}; |
| 107 |
template<class T> struct is_trivially_move_assignable : integral_constant<bool, false> {}; |
| 108 |
template<class T> struct is_nothrow_move_assignable : integral_constant<bool, false> {}; |
| 109 |
|
| 110 |
template<class T> struct is_destructible : integral_constant<bool, false> {}; |
| 111 |
template<class T> struct is_trivially_destructible : integral_constant<bool, false> {}; |
| 112 |
template<class T> struct is_nothrow_destructible : integral_constant<bool, false> {}; |
| 113 |
|
| 114 |
template<class T> struct has_virtual_destructor : integral_constant<bool, false> {}; |
| 115 |
|
| 116 |
// property queries |
| 117 |
template<class T> struct alignment_of : integral_constant<size_t, 0> {}; |
| 118 |
template<class T> struct rank : integral_constant<size_t, 0> {}; |
| 119 |
template<class T, unsigned I = 0> struct extent : integral_constant<size_t, 0> {}; |
| 120 |
|
| 121 |
// type relationships |
| 122 |
template<class T, class U> struct is_same : integral_constant<bool, false> {}; |
| 123 |
template<class Base, class Derived> struct is_base_of : integral_constant<bool, false> {}; |
| 124 |
template<class From, class To> struct is_convertible : integral_constant<bool, false> {}; |
| 125 |
|
| 126 |
// const-volatility specifiers |
| 127 |
template<class T> struct remove_cv { |
| 128 |
typedef T type; |
| 129 |
}; |
| 130 |
template<class T> struct remove_const { |
| 131 |
typedef T type; |
| 132 |
}; |
| 133 |
template<class T> struct remove_volatile { |
| 134 |
typedef T type; |
| 135 |
}; |
| 136 |
template<class T> struct add_cv { |
| 137 |
typedef T type; |
| 138 |
}; |
| 139 |
template<class T> struct add_const { |
| 140 |
typedef T type; |
| 141 |
}; |
| 142 |
template<class T> struct add_volatile { |
| 143 |
typedef T type; |
| 144 |
}; |
| 145 |
|
| 146 |
// references |
| 147 |
template<class T> struct remove_reference { |
| 148 |
typedef T type; |
| 149 |
}; |
| 150 |
template<class T> struct add_lvalue_reference { |
| 151 |
typedef T type; |
| 152 |
}; |
| 153 |
template<class T> struct add_rvalue_reference { |
| 154 |
typedef T type; |
| 155 |
}; |
| 156 |
|
| 157 |
// pointers |
| 158 |
template<class T> struct remove_pointer { |
| 159 |
typedef T type; |
| 160 |
}; |
| 161 |
template<class T> struct add_pointer { |
| 162 |
typedef T type; |
| 163 |
}; |
| 164 |
|
| 165 |
// sign modifiers |
| 166 |
template<class T> struct make_signed { |
| 167 |
typedef T type; |
| 168 |
}; |
| 169 |
template<class T> struct make_unsigned { |
| 170 |
typedef T type; |
| 171 |
}; |
| 172 |
|
| 173 |
// arrays |
| 174 |
template<class T> struct remove_extent { |
| 175 |
typedef T type; |
| 176 |
}; |
| 177 |
template<class T> struct remove_all_extents { |
| 178 |
typedef T type; |
| 179 |
}; |
| 180 |
|
| 181 |
// miscellaneous transformations |
| 182 |
template<size_t Len, size_t Align = 0> struct aligned_storage { |
| 183 |
typedef int type; |
| 184 |
}; |
| 185 |
template<size_t Len, class... Types> struct aligned_union { |
| 186 |
typedef int type; |
| 187 |
}; |
| 188 |
template<class T> struct decay { |
| 189 |
typedef int type; |
| 190 |
}; |
| 191 |
template<bool, class T = void> struct enable_if { |
| 192 |
typedef int type; |
| 193 |
}; |
| 194 |
template<bool, class T, class F> struct conditional { |
| 195 |
typedef int type; |
| 196 |
}; |
| 197 |
template<class... T> struct common_type { |
| 198 |
typedef int type; |
| 199 |
}; |
| 200 |
template<class T> struct underlying_type { |
| 201 |
typedef int type; |
| 202 |
}; |
| 203 |
template<class... ArgTypes> class result_of { |
| 204 |
typedef int type; |
| 205 |
}; // SIMPLIFIED: removed specializatio |
| 206 |
|
| 207 |
} // namespace std |
| 208 |
|
| 209 |
#endif // CPPREFERENCE_STDVER>= 2011 |
| 210 |
|
| 211 |
#endif // CPPREFERENCE_TYPE_TRAITS_H |