1 | //===-- make_signed type_traits ---------------------------------*- C++ -*-===// |
---|---|
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 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H |
9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H |
10 | |
11 | #include "src/__support/CPP/type_traits/type_identity.h" |
12 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128 |
13 | |
14 | namespace LIBC_NAMESPACE::cpp { |
15 | |
16 | // make_signed |
17 | template <typename T> struct make_signed; |
18 | template <> struct make_signed<char> : type_identity<char> {}; |
19 | template <> struct make_signed<signed char> : type_identity<char> {}; |
20 | template <> struct make_signed<short> : type_identity<short> {}; |
21 | template <> struct make_signed<int> : type_identity<int> {}; |
22 | template <> struct make_signed<long> : type_identity<long> {}; |
23 | template <> struct make_signed<long long> : type_identity<long long> {}; |
24 | template <> struct make_signed<unsigned char> : type_identity<char> {}; |
25 | template <> struct make_signed<unsigned short> : type_identity<short> {}; |
26 | template <> struct make_signed<unsigned int> : type_identity<int> {}; |
27 | template <> struct make_signed<unsigned long> : type_identity<long> {}; |
28 | template <> |
29 | struct make_signed<unsigned long long> : type_identity<long long> {}; |
30 | #ifdef LIBC_TYPES_HAS_INT128 |
31 | template <> struct make_signed<__int128_t> : type_identity<__int128_t> {}; |
32 | template <> struct make_signed<__uint128_t> : type_identity<__int128_t> {}; |
33 | #endif |
34 | template <typename T> using make_signed_t = typename make_signed<T>::type; |
35 | |
36 | } // namespace LIBC_NAMESPACE::cpp |
37 | |
38 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H |
39 |