Warning: This file is not a C or C++ file. It does not have highlighting.
1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef _LIBCPP___TYPE_TRAITS_INTEGER_TRAITS_H |
10 | #define _LIBCPP___TYPE_TRAITS_INTEGER_TRAITS_H |
11 | |
12 | #include <__config> |
13 | |
14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
15 | # pragma GCC system_header |
16 | #endif |
17 | |
18 | _LIBCPP_BEGIN_NAMESPACE_STD |
19 | |
20 | // This trait is to determine whether a type is a /signed integer type/ |
21 | // See [basic.fundamental]/p1 |
22 | template <class _Tp> |
23 | inline const bool __is_signed_integer_v = false; |
24 | template <> |
25 | inline const bool __is_signed_integer_v<signed char> = true; |
26 | template <> |
27 | inline const bool __is_signed_integer_v<signed short> = true; |
28 | template <> |
29 | inline const bool __is_signed_integer_v<signed int> = true; |
30 | template <> |
31 | inline const bool __is_signed_integer_v<signed long> = true; |
32 | template <> |
33 | inline const bool __is_signed_integer_v<signed long long> = true; |
34 | #if _LIBCPP_HAS_INT128 |
35 | template <> |
36 | inline const bool __is_signed_integer_v<__int128_t> = true; |
37 | #endif |
38 | |
39 | // This trait is to determine whether a type is an /unsigned integer type/ |
40 | // See [basic.fundamental]/p2 |
41 | template <class _Tp> |
42 | inline const bool __is_unsigned_integer_v = false; |
43 | template <> |
44 | inline const bool __is_unsigned_integer_v<unsigned char> = true; |
45 | template <> |
46 | inline const bool __is_unsigned_integer_v<unsigned short> = true; |
47 | template <> |
48 | inline const bool __is_unsigned_integer_v<unsigned int> = true; |
49 | template <> |
50 | inline const bool __is_unsigned_integer_v<unsigned long> = true; |
51 | template <> |
52 | inline const bool __is_unsigned_integer_v<unsigned long long> = true; |
53 | #if _LIBCPP_HAS_INT128 |
54 | template <> |
55 | inline const bool __is_unsigned_integer_v<__uint128_t> = true; |
56 | #endif |
57 | |
58 | #if _LIBCPP_STD_VER >= 20 |
59 | template <class _Tp> |
60 | concept __signed_integer = __is_signed_integer_v<_Tp>; |
61 | |
62 | template <class _Tp> |
63 | concept __unsigned_integer = __is_unsigned_integer_v<_Tp>; |
64 | |
65 | // This isn't called __integer, because an integer type according to [basic.fundamental]/p11 is the same as an integral |
66 | // type. An integral type is _not_ the same set of types as signed and unsigned integer types combined. |
67 | template <class _Tp> |
68 | concept __signed_or_unsigned_integer = __signed_integer<_Tp> || __unsigned_integer<_Tp>; |
69 | #endif |
70 | |
71 | _LIBCPP_END_NAMESPACE_STD |
72 | |
73 | #endif // _LIBCPP___TYPE_TRAITS_INTEGER_TRAITS_H |
74 |
Warning: This file is not a C or C++ file. It does not have highlighting.