diff options
author | Lenny Maiorani <lenny@colorado.edu> | 2020-11-11 15:21:01 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-12 10:19:04 +0100 |
commit | f5ced347e65f06e835fa8f0333d69e803f5a8a72 (patch) | |
tree | 16a8f1a7eba6bd72e65333deca3781c54119cf51 /AK/StdLibExtras.h | |
parent | 6b97118e89670f636e9c4de01b10cbab58dcc0db (diff) | |
download | serenity-f5ced347e65f06e835fa8f0333d69e803f5a8a72.zip |
AK: Prefer using instead of typedef
Problem:
- `typedef` is a keyword which comes from C and carries with it old
syntax that is hard to read.
- Creating type aliases with the `using` keyword allows for easier
future maintenance because it supports template syntax.
- There is inconsistent use of `typedef` vs `using`.
Solution:
- Use `clang-tidy`'s checker called `modernize-use-using` to update
the syntax to use the newer syntax.
- Remove unused functions to make `clang-tidy` happy.
- This results in consistency within the codebase.
Diffstat (limited to 'AK/StdLibExtras.h')
-rw-r--r-- | AK/StdLibExtras.h | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 25eadfb541..0973c59455 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -104,48 +104,48 @@ struct EnableIf { template<class T> struct EnableIf<true, T> { - typedef T Type; + using Type = T; }; template<class T> struct AddConst { - typedef const T Type; + using Type = const T; }; template<class T> struct RemoveConst { - typedef T Type; + using Type = T; }; template<class T> struct RemoveConst<const T> { - typedef T Type; + using Type = T; }; template<class T> struct RemoveVolatile { - typedef T Type; + using Type = T; }; template<class T> struct RemoveVolatile<volatile T> { - typedef T Type; + using Type = T; }; template<class T> struct RemoveCV { - typedef typename RemoveVolatile<typename RemoveConst<T>::Type>::Type Type; + using Type = typename RemoveVolatile<typename RemoveConst<T>::Type>::Type; }; template<class T, T v> struct IntegralConstant { static constexpr T value = v; - typedef T ValueType; - typedef IntegralConstant Type; + using ValueType = T; + using Type = IntegralConstant; constexpr operator ValueType() const { return value; } constexpr ValueType operator()() const { return value; } }; -typedef IntegralConstant<bool, false> FalseType; -typedef IntegralConstant<bool, true> TrueType; +using FalseType = IntegralConstant<bool, false>; +using TrueType = IntegralConstant<bool, true>; template<typename...> using VoidType = void; @@ -257,23 +257,23 @@ struct IsRvalueReference<T&&> : TrueType { template<class T> struct RemovePointer { - typedef T Type; + using Type = T; }; template<class T> struct RemovePointer<T*> { - typedef T Type; + using Type = T; }; template<class T> struct RemovePointer<T* const> { - typedef T Type; + using Type = T; }; template<class T> struct RemovePointer<T* volatile> { - typedef T Type; + using Type = T; }; template<class T> struct RemovePointer<T* const volatile> { - typedef T Type; + using Type = T; }; template<typename T, typename U> @@ -292,12 +292,12 @@ struct IsSame<T, T> { template<bool condition, class TrueType, class FalseType> struct Conditional { - typedef TrueType Type; + using Type = TrueType; }; template<class TrueType, class FalseType> struct Conditional<false, TrueType, FalseType> { - typedef FalseType Type; + using Type = FalseType; }; template<typename T> @@ -306,15 +306,15 @@ struct IsNullPointer : IsSame<decltype(nullptr), typename RemoveCV<T>::Type> { template<typename T> struct RemoveReference { - typedef T Type; + using Type = T; }; template<class T> struct RemoveReference<T&> { - typedef T Type; + using Type = T; }; template<class T> struct RemoveReference<T&&> { - typedef T Type; + using Type = T; }; template<class T> @@ -335,47 +335,47 @@ struct MakeUnsigned { }; template<> struct MakeUnsigned<signed char> { - typedef unsigned char Type; + using Type = unsigned char; }; template<> struct MakeUnsigned<short> { - typedef unsigned short Type; + using Type = unsigned short; }; template<> struct MakeUnsigned<int> { - typedef unsigned Type; + using Type = unsigned int; }; template<> struct MakeUnsigned<long> { - typedef unsigned long Type; + using Type = unsigned long; }; template<> struct MakeUnsigned<long long> { - typedef unsigned long long Type; + using Type = unsigned long long; }; template<> struct MakeUnsigned<unsigned char> { - typedef unsigned char Type; + using Type = unsigned char; }; template<> struct MakeUnsigned<unsigned short> { - typedef unsigned short Type; + using Type = unsigned short; }; template<> struct MakeUnsigned<unsigned int> { - typedef unsigned Type; + using Type = unsigned int; }; template<> struct MakeUnsigned<unsigned long> { - typedef unsigned long Type; + using Type = unsigned long; }; template<> struct MakeUnsigned<unsigned long long> { - typedef unsigned long long Type; + using Type = unsigned long long; }; template<> struct MakeUnsigned<char> { - typedef unsigned char Type; + using Type = unsigned char; }; template<typename T> @@ -383,47 +383,47 @@ struct MakeSigned { }; template<> struct MakeSigned<signed char> { - typedef signed char Type; + using Type = signed char; }; template<> struct MakeSigned<short> { - typedef short Type; + using Type = short; }; template<> struct MakeSigned<int> { - typedef int Type; + using Type = int; }; template<> struct MakeSigned<long> { - typedef long Type; + using Type = long; }; template<> struct MakeSigned<long long> { - typedef long long Type; + using Type = long long; }; template<> struct MakeSigned<unsigned char> { - typedef char Type; + using Type = char; }; template<> struct MakeSigned<unsigned short> { - typedef short Type; + using Type = short; }; template<> struct MakeSigned<unsigned int> { - typedef int Type; + using Type = int; }; template<> struct MakeSigned<unsigned long> { - typedef long Type; + using Type = long; }; template<> struct MakeSigned<unsigned long long> { - typedef long long Type; + using Type = long long; }; template<> struct MakeSigned<char> { - typedef signed char Type; + using Type = signed char; }; template<class T> |