Simple-Utility v2.3.1
Loading...
Searching...
No Matches
TypeTraits.hpp
Go to the documentation of this file.
1// Copyright Dominic Koepke 2019 - 2023.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// https://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef SIMPLE_UTILITY_TYPE_TRAITS_HPP
7#define SIMPLE_UTILITY_TYPE_TRAITS_HPP
8
9#include <type_traits>
10
12
13namespace sl
14{
30 template <class T>
32 {
33 using type = T;
34 };
35
40 template <class T>
42
47 template <concepts::reference T>
49 {
51 };
52
57 template <concepts::pointer T>
58 struct cv_qualified_type<T>
59 {
61 };
62
81 template <class T>
83 {
84 using type = const T;
85 };
86
91 template <class T>
93
98 template <class T>
99 struct add_type_const<T&>
100 {
102 };
103
108 template <class T>
109 struct add_type_const<T&&>
110 {
112 };
113
118 template <class T>
119 struct add_type_const<T*>
120 {
122 };
123
128 template <class T>
129 struct add_type_const<T* volatile>
130 {
131 using type = add_type_const_t<T>* volatile;
132 };
133
138 template <class T>
139 struct add_type_const<T* const>
140 {
141 using type = add_type_const_t<T>* const;
142 };
143
148 template <class T>
149 struct add_type_const<T* const volatile>
150 {
151 using type = add_type_const_t<T>* const volatile;
152 };
153
172 template <class T>
174 {
175 using type = std::remove_const_t<T>;
176 };
177
182 template <class T>
184
189 template <class T>
191 {
193 };
194
199 template <class T>
201 {
203 };
204
209 template <class T>
211 {
213 };
214
219 template <class T>
220 struct remove_type_const<T* volatile>
221 {
222 using type = remove_type_const_t<T>* volatile;
223 };
224
229 template <class T>
230 struct remove_type_const<T* const>
231 {
233 };
234
239 template <class T>
240 struct remove_type_const<T* const volatile>
241 {
242 using type = remove_type_const_t<T>* const volatile;
243 };
244
263 template <class T>
265 {
266 using type = volatile T;
267 };
268
273 template <class T>
275
280 template <class T>
282 {
284 };
285
290 template <class T>
292 {
294 };
295
300 template <class T>
302 {
304 };
305
310 template <class T>
311 struct add_type_volatile<T* volatile>
312 {
313 using type = add_type_volatile_t<T>* volatile;
314 };
315
320 template <class T>
321 struct add_type_volatile<T* const>
322 {
324 };
325
330 template <class T>
331 struct add_type_volatile<T* const volatile>
332 {
333 using type = add_type_volatile_t<T>* const volatile;
334 };
335
354 template <class T>
356 {
357 using type = std::remove_volatile_t<T>;
358 };
359
364 template <class T>
366
371 template <class T>
373 {
375 };
376
381 template <class T>
383 {
385 };
386
391 template <class T>
393 {
395 };
396
401 template <class T>
402 struct remove_type_volatile<T* volatile>
403 {
405 };
406
411 template <class T>
412 struct remove_type_volatile<T* const>
413 {
415 };
416
421 template <class T>
422 struct remove_type_volatile<T* const volatile>
423 {
424 using type = remove_type_volatile_t<T>* const volatile;
425 };
426
445 template <class T>
447 {
449 };
450
455 template <class T>
457
476 template <class T>
478 {
480 };
481
486 template <class T>
488
506 template <class To, class From>
508 {
509 using type = std::remove_reference_t<To>;
510 };
511
517 template <class To, class From>
518 struct value_category_as<To, From&>
519 {
520 using type = std::add_lvalue_reference_t<To>;
521 };
522
528 template <class To, class From>
529 struct value_category_as<To, From&&>
530 {
531 using type = std::add_rvalue_reference_t<std::remove_reference_t<To>>;
532 };
533
539 template <class To, class From>
541
558 template <class To, class From>
560 {
561 using type = std::conditional_t<
562 std::is_const_v<cv_qualified_type_t<From>>,
565 };
566
572 template <class To, class From>
574
591 template <class To, class From>
593 {
594 using type = std::conditional_t<
595 std::is_volatile_v<cv_qualified_type_t<From>>,
598 };
599
605 template <class To, class From>
607
624 template <class To, class From>
626 {
629 From>;
630 };
631
637 template <class To, class From>
639
652 template <class To, class From>
654 {
657 From>;
658 };
659
665 template <class To, class From>
667
671}
672
673#endif
typename add_type_const< T >::type add_type_const_t
Convenience alias, exposing the type member alias of the add_type_const trait.
Definition: TypeTraits.hpp:92
typename add_type_cv< T >::type add_type_cv_t
Convenience alias, exposing the type member alias of the add_type_cv trait.
Definition: TypeTraits.hpp:456
typename add_type_volatile< T >::type add_type_volatile_t
Convenience alias, exposing the type member alias of the add_type_volatile trait.
Definition: TypeTraits.hpp:274
typename cv_qualified_type< T >::type cv_qualified_type_t
Convenience alias, exposing the type member alias of the cv_qualified_type trait.
Definition: TypeTraits.hpp:41
typename qualified_category_as< To, From >::type qualified_category_as_t
Convenience alias, exposing the type member alias of the qualified_category_as trait.
Definition: TypeTraits.hpp:666
typename remove_type_const< T >::type remove_type_const_t
Convenience alias, exposing the type member alias of the remove_type_const trait.
Definition: TypeTraits.hpp:183
typename type_constness_as< To, From >::type type_constness_as_t
Convenience alias, exposing the type member alias of the type_constness_as trait.
Definition: TypeTraits.hpp:573
typename remove_type_cv< T >::type remove_type_cv_t
Convenience alias, exposing the type member alias of the remove_type_cv trait.
Definition: TypeTraits.hpp:487
typename type_qualification_as< To, From >::type type_qualification_as_t
Convenience alias, exposing the type member alias of the type_qualification_as trait.
Definition: TypeTraits.hpp:638
typename remove_type_volatile< T >::type remove_type_volatile_t
Convenience alias, exposing the type member alias of the remove_type_volatile trait.
Definition: TypeTraits.hpp:365
typename type_volatileness_as< To, From >::type type_volatileness_as_t
Convenience alias, exposing the type member alias of the type_volatileness_as trait.
Definition: TypeTraits.hpp:606
typename value_category_as< To, From >::type value_category_as_t
Convenience alias, exposing the type member alias of the value_category_as trait.
Definition: TypeTraits.hpp:540
Definition: operators.hpp:15
add_type_const_t< T > * type
Definition: TypeTraits.hpp:121
add_type_const_t< T > *const type
Definition: TypeTraits.hpp:141
add_type_const_t< T > *const volatile type
Definition: TypeTraits.hpp:151
add_type_const_t< T > *volatile type
Definition: TypeTraits.hpp:131
add_type_const_t< T > & type
Definition: TypeTraits.hpp:101
add_type_const_t< T > && type
Definition: TypeTraits.hpp:111
Primary template, adding const to value types.
Definition: TypeTraits.hpp:83
const T type
Definition: TypeTraits.hpp:84
Primary template, adding const and volatile to value types.
Definition: TypeTraits.hpp:447
add_type_const_t< add_type_volatile_t< T > > type
Definition: TypeTraits.hpp:448
add_type_volatile_t< T > * type
Definition: TypeTraits.hpp:303
add_type_volatile_t< T > *const type
Definition: TypeTraits.hpp:323
add_type_volatile_t< T > *const volatile type
Definition: TypeTraits.hpp:333
add_type_volatile_t< T > *volatile type
Definition: TypeTraits.hpp:313
add_type_volatile_t< T > & type
Definition: TypeTraits.hpp:283
add_type_volatile_t< T > && type
Definition: TypeTraits.hpp:293
Primary template, adding volatile to value types.
Definition: TypeTraits.hpp:265
volatile T type
Definition: TypeTraits.hpp:266
cv_qualified_type_t< std::remove_reference_t< T > > type
Definition: TypeTraits.hpp:50
Primary template, taking the T as-is.
Definition: TypeTraits.hpp:32
T type
Definition: TypeTraits.hpp:33
Definition: TypeTraits.hpp:654
value_category_as_t< type_qualification_as_t< To, From >, From > type
Definition: TypeTraits.hpp:657
remove_type_const_t< T > * type
Definition: TypeTraits.hpp:212
remove_type_const_t< T > *const type
Definition: TypeTraits.hpp:232
remove_type_const_t< T > *const volatile type
Definition: TypeTraits.hpp:242
remove_type_const_t< T > *volatile type
Definition: TypeTraits.hpp:222
remove_type_const_t< T > & type
Definition: TypeTraits.hpp:192
remove_type_const_t< T > && type
Definition: TypeTraits.hpp:202
Primary template, removing const from value types.
Definition: TypeTraits.hpp:174
std::remove_const_t< T > type
Definition: TypeTraits.hpp:175
Primary template, removing const and volatile from value types.
Definition: TypeTraits.hpp:478
remove_type_const_t< remove_type_volatile_t< T > > type
Definition: TypeTraits.hpp:479
remove_type_volatile_t< T > * type
Definition: TypeTraits.hpp:394
remove_type_volatile_t< T > *const type
Definition: TypeTraits.hpp:414
remove_type_volatile_t< T > *const volatile type
Definition: TypeTraits.hpp:424
remove_type_volatile_t< T > *volatile type
Definition: TypeTraits.hpp:404
remove_type_volatile_t< T > & type
Definition: TypeTraits.hpp:374
remove_type_volatile_t< T > && type
Definition: TypeTraits.hpp:384
Primary template, removing volatile from value types.
Definition: TypeTraits.hpp:356
std::remove_volatile_t< T > type
Definition: TypeTraits.hpp:357
Applies or removes the const qualification of To in regards of From.
Definition: TypeTraits.hpp:560
std::conditional_t< std::is_const_v< cv_qualified_type_t< From > >, add_type_const_t< To >, remove_type_const_t< To > > type
Definition: TypeTraits.hpp:564
Applies or removes the const and/or volatile qualifications of To in regards of From.
Definition: TypeTraits.hpp:626
type_constness_as_t< type_volatileness_as_t< To, From >, From > type
Definition: TypeTraits.hpp:629
Applies or removes the volatile qualification of To in regards of From.
Definition: TypeTraits.hpp:593
std::conditional_t< std::is_volatile_v< cv_qualified_type_t< From > >, add_type_volatile_t< To >, remove_type_volatile_t< To > > type
Definition: TypeTraits.hpp:597
std::add_lvalue_reference_t< To > type
Definition: TypeTraits.hpp:520
std::add_rvalue_reference_t< std::remove_reference_t< To > > type
Definition: TypeTraits.hpp:531
Primary template, removing any reference category.
Definition: TypeTraits.hpp:508
std::remove_reference_t< To > type
Definition: TypeTraits.hpp:509