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