Quellcode durchsuchen

AK: Define MakeUnsigned and MakeSigned for char.

For some weird reason the C++ standard considers char, signed char and
unsigned char *three* different types. On the other hand int is just an
alias for signed int, meaning that int, signed int and unsigned int are
just *two* different types.

https://stackoverflow.com/a/32856568/8746648
asynts vor 4 Jahren
Ursprung
Commit
1b3169f405
1 geänderte Dateien mit 8 neuen und 20 gelöschten Zeilen
  1. 8 20
      AK/StdLibExtras.h

+ 8 - 20
AK/StdLibExtras.h

@@ -329,110 +329,98 @@ inline constexpr T&& forward(typename RemoveReference<T>::Type&& param) noexcept
 template<typename T>
 struct MakeUnsigned {
 };
-
 template<>
 struct MakeUnsigned<signed char> {
     typedef unsigned char Type;
 };
-
 template<>
 struct MakeUnsigned<short> {
     typedef unsigned short Type;
 };
-
 template<>
 struct MakeUnsigned<int> {
     typedef unsigned Type;
 };
-
 template<>
 struct MakeUnsigned<long> {
     typedef unsigned long Type;
 };
-
 template<>
 struct MakeUnsigned<long long> {
     typedef unsigned long long Type;
 };
-
 template<>
 struct MakeUnsigned<unsigned char> {
     typedef unsigned char Type;
 };
-
 template<>
 struct MakeUnsigned<unsigned short> {
     typedef unsigned short Type;
 };
-
 template<>
 struct MakeUnsigned<unsigned int> {
     typedef unsigned Type;
 };
-
 template<>
 struct MakeUnsigned<unsigned long> {
     typedef unsigned long Type;
 };
-
 template<>
 struct MakeUnsigned<unsigned long long> {
     typedef unsigned long long Type;
 };
+template<>
+struct MakeUnsigned<char> {
+    typedef unsigned char Type;
+};
 
 template<typename T>
 struct MakeSigned {
 };
-
 template<>
 struct MakeSigned<signed char> {
     typedef signed char Type;
 };
-
 template<>
 struct MakeSigned<short> {
     typedef short Type;
 };
-
 template<>
 struct MakeSigned<int> {
     typedef int Type;
 };
-
 template<>
 struct MakeSigned<long> {
     typedef long Type;
 };
-
 template<>
 struct MakeSigned<long long> {
     typedef long long Type;
 };
-
 template<>
 struct MakeSigned<unsigned char> {
     typedef char Type;
 };
-
 template<>
 struct MakeSigned<unsigned short> {
     typedef short Type;
 };
-
 template<>
 struct MakeSigned<unsigned int> {
     typedef int Type;
 };
-
 template<>
 struct MakeSigned<unsigned long> {
     typedef long Type;
 };
-
 template<>
 struct MakeSigned<unsigned long long> {
     typedef long long Type;
 };
+template<>
+struct MakeSigned<char> {
+    typedef signed char Type;
+};
 
 template<class T>
 struct IsVoid : IsSame<void, typename RemoveCV<T>::Type> {