Skip to content

Commit de0e6e0

Browse files
committed
[libc++][NFC] Remove dead code from make_{signed,unsigned}
1 parent 8a2113c commit de0e6e0

File tree

3 files changed

+24
-87
lines changed

3 files changed

+24
-87
lines changed

libcxx/include/__type_traits/make_signed.h

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111

1212
#include <__config>
1313
#include <__type_traits/copy_cv.h>
14-
#include <__type_traits/is_enum.h>
15-
#include <__type_traits/is_integral.h>
16-
#include <__type_traits/nat.h>
1714
#include <__type_traits/remove_cv.h>
18-
#include <__type_traits/type_list.h>
1915

2016
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2117
# pragma GCC system_header
@@ -29,43 +25,22 @@ template <class _Tp>
2925
using __make_signed_t = __make_signed(_Tp);
3026

3127
#else
32-
// clang-format off
33-
typedef __type_list<signed char,
34-
__type_list<signed short,
35-
__type_list<signed int,
36-
__type_list<signed long,
37-
__type_list<signed long long,
38-
# if _LIBCPP_HAS_INT128
39-
__type_list<__int128_t,
40-
# endif
41-
__nat
42-
# if _LIBCPP_HAS_INT128
43-
>
44-
# endif
45-
> > > > > __signed_types;
46-
// clang-format on
47-
48-
template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
49-
struct __make_signed{};
50-
5128
template <class _Tp>
52-
struct __make_signed<_Tp, true> {
53-
typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
54-
};
29+
struct __make_signed{};
5530

5631
// clang-format off
57-
template <> struct __make_signed<bool, true> {};
58-
template <> struct __make_signed< signed short, true> {typedef short type;};
59-
template <> struct __make_signed<unsigned short, true> {typedef short type;};
60-
template <> struct __make_signed< signed int, true> {typedef int type;};
61-
template <> struct __make_signed<unsigned int, true> {typedef int type;};
62-
template <> struct __make_signed< signed long, true> {typedef long type;};
63-
template <> struct __make_signed<unsigned long, true> {typedef long type;};
64-
template <> struct __make_signed< signed long long, true> {typedef long long type;};
65-
template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
32+
template <> struct __make_signed<bool > {};
33+
template <> struct __make_signed< signed short > {typedef short type;};
34+
template <> struct __make_signed<unsigned short > {typedef short type;};
35+
template <> struct __make_signed< signed int > {typedef int type;};
36+
template <> struct __make_signed<unsigned int > {typedef int type;};
37+
template <> struct __make_signed< signed long > {typedef long type;};
38+
template <> struct __make_signed<unsigned long > {typedef long type;};
39+
template <> struct __make_signed< signed long long> {typedef long long type;};
40+
template <> struct __make_signed<unsigned long long> {typedef long long type;};
6641
# if _LIBCPP_HAS_INT128
67-
template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
68-
template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
42+
template <> struct __make_signed<__int128_t > {typedef __int128_t type;};
43+
template <> struct __make_signed<__uint128_t > {typedef __int128_t type;};
6944
# endif
7045
// clang-format on
7146

libcxx/include/__type_traits/make_unsigned.h

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@
1212
#include <__config>
1313
#include <__type_traits/conditional.h>
1414
#include <__type_traits/copy_cv.h>
15-
#include <__type_traits/is_enum.h>
16-
#include <__type_traits/is_integral.h>
1715
#include <__type_traits/is_unsigned.h>
18-
#include <__type_traits/nat.h>
1916
#include <__type_traits/remove_cv.h>
20-
#include <__type_traits/type_list.h>
2117

2218
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2319
# pragma GCC system_header
@@ -31,43 +27,23 @@ template <class _Tp>
3127
using __make_unsigned_t = __make_unsigned(_Tp);
3228

3329
#else
34-
// clang-format off
35-
typedef __type_list<unsigned char,
36-
__type_list<unsigned short,
37-
__type_list<unsigned int,
38-
__type_list<unsigned long,
39-
__type_list<unsigned long long,
40-
# if _LIBCPP_HAS_INT128
41-
__type_list<__uint128_t,
42-
# endif
43-
__nat
44-
# if _LIBCPP_HAS_INT128
45-
>
46-
# endif
47-
> > > > > __unsigned_types;
48-
// clang-format on
49-
50-
template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
51-
struct __make_unsigned{};
5230

5331
template <class _Tp>
54-
struct __make_unsigned<_Tp, true> {
55-
typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
56-
};
32+
struct __make_unsigned{};
5733

5834
// clang-format off
59-
template <> struct __make_unsigned<bool, true> {};
60-
template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
61-
template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
62-
template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
63-
template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
64-
template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
65-
template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
66-
template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
67-
template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
35+
template <> struct __make_unsigned<bool > {};
36+
template <> struct __make_unsigned< signed short > {typedef unsigned short type;};
37+
template <> struct __make_unsigned<unsigned short > {typedef unsigned short type;};
38+
template <> struct __make_unsigned< signed int > {typedef unsigned int type;};
39+
template <> struct __make_unsigned<unsigned int > {typedef unsigned int type;};
40+
template <> struct __make_unsigned< signed long > {typedef unsigned long type;};
41+
template <> struct __make_unsigned<unsigned long > {typedef unsigned long type;};
42+
template <> struct __make_unsigned< signed long long> {typedef unsigned long long type;};
43+
template <> struct __make_unsigned<unsigned long long> {typedef unsigned long long type;};
6844
# if _LIBCPP_HAS_INT128
69-
template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
70-
template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
45+
template <> struct __make_unsigned<__int128_t > {typedef __uint128_t type;};
46+
template <> struct __make_unsigned<__uint128_t > {typedef __uint128_t type;};
7147
# endif
7248
// clang-format on
7349

libcxx/include/__type_traits/type_list.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H
1111

1212
#include <__config>
13-
#include <__cstddef/size_t.h>
1413

1514
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1615
# pragma GCC system_header
@@ -24,19 +23,6 @@ struct __type_list {
2423
typedef _Tp _Tail;
2524
};
2625

27-
template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)>
28-
struct __find_first;
29-
30-
template <class _Hp, class _Tp, size_t _Size>
31-
struct __find_first<__type_list<_Hp, _Tp>, _Size, true> {
32-
typedef _LIBCPP_NODEBUG _Hp type;
33-
};
34-
35-
template <class _Hp, class _Tp, size_t _Size>
36-
struct __find_first<__type_list<_Hp, _Tp>, _Size, false> {
37-
typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type;
38-
};
39-
4026
_LIBCPP_END_NAMESPACE_STD
4127

4228
#endif // _LIBCPP___TYPE_TRAITS_TYPE_LIST_H

0 commit comments

Comments
 (0)