diff --git a/AK/DistinctNumeric.h b/AK/DistinctNumeric.h index 38775f95b25..4625634b268 100644 --- a/AK/DistinctNumeric.h +++ b/AK/DistinctNumeric.h @@ -66,7 +66,7 @@ namespace AK { */ template class DistinctNumeric { - typedef DistinctNumeric Self; + using Self = DistinctNumeric; public: DistinctNumeric(T value) @@ -301,8 +301,8 @@ private: } #define TYPEDEF_DISTINCT_NUMERIC_GENERAL(T, Incr, Cmp, Bool, Flags, Shift, Arith, NAME) \ - typedef DistinctNumeric NAME + using NAME = DistinctNumeric; #define TYPEDEF_DISTINCT_ORDERED_ID(T, NAME) TYPEDEF_DISTINCT_NUMERIC_GENERAL(T, false, true, true, false, false, false, NAME) -// TODO: Further typedef's? +// TODO: Further type aliases? using AK::DistinctNumeric; diff --git a/AK/HashMap.h b/AK/HashMap.h index 33e982cb332..cf1c8e22f12 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -67,9 +67,9 @@ public: } void remove_one_randomly() { m_table.remove(m_table.begin()); } - typedef HashTable HashTableType; - typedef typename HashTableType::Iterator IteratorType; - typedef typename HashTableType::ConstIterator ConstIteratorType; + using HashTableType = HashTable; + using IteratorType = typename HashTableType::Iterator; + using ConstIteratorType = typename HashTableType::ConstIterator; IteratorType begin() { return m_table.begin(); } IteratorType end() { return m_table.end(); } diff --git a/AK/NonnullOwnPtr.h b/AK/NonnullOwnPtr.h index 3d430e167da..d06895f6420 100644 --- a/AK/NonnullOwnPtr.h +++ b/AK/NonnullOwnPtr.h @@ -45,7 +45,7 @@ class WeakPtr; template class NonnullOwnPtr { public: - typedef T ElementType; + using ElementType = T; enum AdoptTag { Adopt }; diff --git a/AK/NonnullPtrVector.h b/AK/NonnullPtrVector.h index 3698015974f..31b42102a53 100644 --- a/AK/NonnullPtrVector.h +++ b/AK/NonnullPtrVector.h @@ -32,8 +32,8 @@ namespace AK { template class NonnullPtrVector : public Vector { - typedef typename PtrType::ElementType T; - typedef Vector Base; + using T = typename PtrType::ElementType; + using Base = Vector; public: NonnullPtrVector() diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index 04e55a0985d..a3b83091396 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -66,7 +66,7 @@ class NonnullRefPtr { friend class WeakPtr; public: - typedef T ElementType; + using ElementType = T; enum AdoptTag { Adopt }; diff --git a/AK/RefCounted.h b/AK/RefCounted.h index fac57602705..77b480bdbf9 100644 --- a/AK/RefCounted.h +++ b/AK/RefCounted.h @@ -64,7 +64,7 @@ class RefCountedBase { AK_MAKE_NONMOVABLE(RefCountedBase); public: - typedef unsigned int RefCountType; + using RefCountType = unsigned int; using AllowOwnPtr = FalseType; ALWAYS_INLINE void ref() const @@ -111,16 +111,6 @@ public: } }; -static constexpr bool is_ref_counted(const RefCountedBase*) -{ - return true; -} - -static constexpr bool is_ref_counted(...) -{ - return false; -} - } using AK::RefCounted; diff --git a/AK/RefPtr.h b/AK/RefPtr.h index aef74bd6da5..ecdf9973e4d 100644 --- a/AK/RefPtr.h +++ b/AK/RefPtr.h @@ -128,7 +128,7 @@ struct RefPtrTraits { static constexpr FlatPtr default_null_value = 0; - typedef std::nullptr_t NullType; + using NullType = std::nullptr_t; }; template diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 25eadfb5412..0973c59455f 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -104,48 +104,48 @@ struct EnableIf { template struct EnableIf { - typedef T Type; + using Type = T; }; template struct AddConst { - typedef const T Type; + using Type = const T; }; template struct RemoveConst { - typedef T Type; + using Type = T; }; template struct RemoveConst { - typedef T Type; + using Type = T; }; template struct RemoveVolatile { - typedef T Type; + using Type = T; }; template struct RemoveVolatile { - typedef T Type; + using Type = T; }; template struct RemoveCV { - typedef typename RemoveVolatile::Type>::Type Type; + using Type = typename RemoveVolatile::Type>::Type; }; template 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 FalseType; -typedef IntegralConstant TrueType; +using FalseType = IntegralConstant; +using TrueType = IntegralConstant; template using VoidType = void; @@ -257,23 +257,23 @@ struct IsRvalueReference : TrueType { template struct RemovePointer { - typedef T Type; + using Type = T; }; template struct RemovePointer { - typedef T Type; + using Type = T; }; template struct RemovePointer { - typedef T Type; + using Type = T; }; template struct RemovePointer { - typedef T Type; + using Type = T; }; template struct RemovePointer { - typedef T Type; + using Type = T; }; template @@ -292,12 +292,12 @@ struct IsSame { template struct Conditional { - typedef TrueType Type; + using Type = TrueType; }; template struct Conditional { - typedef FalseType Type; + using Type = FalseType; }; template @@ -306,15 +306,15 @@ struct IsNullPointer : IsSame::Type> { template struct RemoveReference { - typedef T Type; + using Type = T; }; template struct RemoveReference { - typedef T Type; + using Type = T; }; template struct RemoveReference { - typedef T Type; + using Type = T; }; template @@ -335,47 +335,47 @@ struct MakeUnsigned { }; template<> struct MakeUnsigned { - typedef unsigned char Type; + using Type = unsigned char; }; template<> struct MakeUnsigned { - typedef unsigned short Type; + using Type = unsigned short; }; template<> struct MakeUnsigned { - typedef unsigned Type; + using Type = unsigned int; }; template<> struct MakeUnsigned { - typedef unsigned long Type; + using Type = unsigned long; }; template<> struct MakeUnsigned { - typedef unsigned long long Type; + using Type = unsigned long long; }; template<> struct MakeUnsigned { - typedef unsigned char Type; + using Type = unsigned char; }; template<> struct MakeUnsigned { - typedef unsigned short Type; + using Type = unsigned short; }; template<> struct MakeUnsigned { - typedef unsigned Type; + using Type = unsigned int; }; template<> struct MakeUnsigned { - typedef unsigned long Type; + using Type = unsigned long; }; template<> struct MakeUnsigned { - typedef unsigned long long Type; + using Type = unsigned long long; }; template<> struct MakeUnsigned { - typedef unsigned char Type; + using Type = unsigned char; }; template @@ -383,47 +383,47 @@ struct MakeSigned { }; template<> struct MakeSigned { - typedef signed char Type; + using Type = signed char; }; template<> struct MakeSigned { - typedef short Type; + using Type = short; }; template<> struct MakeSigned { - typedef int Type; + using Type = int; }; template<> struct MakeSigned { - typedef long Type; + using Type = long; }; template<> struct MakeSigned { - typedef long long Type; + using Type = long long; }; template<> struct MakeSigned { - typedef char Type; + using Type = char; }; template<> struct MakeSigned { - typedef short Type; + using Type = short; }; template<> struct MakeSigned { - typedef int Type; + using Type = int; }; template<> struct MakeSigned { - typedef long Type; + using Type = long; }; template<> struct MakeSigned { - typedef long long Type; + using Type = long long; }; template<> struct MakeSigned { - typedef signed char Type; + using Type = signed char; }; template diff --git a/AK/Tests/TestHashMap.cpp b/AK/Tests/TestHashMap.cpp index 4a77894f059..b38437600f3 100644 --- a/AK/Tests/TestHashMap.cpp +++ b/AK/Tests/TestHashMap.cpp @@ -31,7 +31,7 @@ TEST_CASE(construct) { - typedef HashMap IntIntMap; + using IntIntMap = HashMap; EXPECT(IntIntMap().is_empty()); EXPECT_EQ(IntIntMap().size(), 0u); } diff --git a/AK/Types.h b/AK/Types.h index 107a3b68d97..7bc56a1f501 100644 --- a/AK/Types.h +++ b/AK/Types.h @@ -30,36 +30,36 @@ #include #include -typedef __UINT64_TYPE__ u64; -typedef __UINT32_TYPE__ u32; -typedef __UINT16_TYPE__ u16; -typedef __UINT8_TYPE__ u8; -typedef __INT64_TYPE__ i64; -typedef __INT32_TYPE__ i32; -typedef __INT16_TYPE__ i16; -typedef __INT8_TYPE__ i8; +using u64 = __UINT64_TYPE__; +using u32 = __UINT32_TYPE__; +using u16 = __UINT16_TYPE__; +using u8 = __UINT8_TYPE__; +using i64 = __INT64_TYPE__; +using i32 = __INT32_TYPE__; +using i16 = __INT16_TYPE__; +using i8 = __INT8_TYPE__; #ifdef __serenity__ -typedef __SIZE_TYPE__ size_t; -typedef MakeSigned::Type ssize_t; +using size_t = __SIZE_TYPE__; +using ssize_t = MakeSigned::Type; -typedef __PTRDIFF_TYPE__ ptrdiff_t; +using ptrdiff_t = __PTRDIFF_TYPE__; -typedef __INTPTR_TYPE__ intptr_t; -typedef __UINTPTR_TYPE__ uintptr_t; +using intptr_t = __INTPTR_TYPE__; +using uintptr_t = __UINTPTR_TYPE__; -typedef u8 uint8_t; -typedef u16 uint16_t; -typedef u32 uint32_t; -typedef u64 uint64_t; +using uint8_t = u8; +using uint16_t = u16; +using uint32_t = u32; +using uint64_t = u64; -typedef i8 int8_t; -typedef i16 int16_t; -typedef i32 int32_t; -typedef i64 int64_t; +using int8_t = i8; +using int16_t = i16; +using int32_t = i32; +using int64_t = i64; -typedef int pid_t; +using pid_t = int; #else # include @@ -67,19 +67,19 @@ typedef int pid_t; # include # ifdef __ptrdiff_t -typedef __PTRDIFF_TYPE__ __ptrdiff_t; +using __ptrdiff_t = __PTRDIFF_TYPE__; # endif #endif -typedef Conditional::Type FlatPtr; +using FlatPtr = Conditional::Type; constexpr unsigned KiB = 1024; constexpr unsigned MiB = KiB * KiB; constexpr unsigned GiB = KiB * KiB * KiB; namespace std { -typedef decltype(nullptr) nullptr_t; +using nullptr_t = decltype(nullptr); } static constexpr u32 explode_byte(u8 b) diff --git a/AK/Utf32View.h b/AK/Utf32View.h index 4c6c7f8a2cc..49b8efb13cc 100644 --- a/AK/Utf32View.h +++ b/AK/Utf32View.h @@ -81,7 +81,7 @@ private: class Utf32View { public: - typedef Utf32CodepointIterator Iterator; + using Iterator = Utf32CodepointIterator; Utf32View() { } Utf32View(const u32* code_points, size_t length) diff --git a/AK/Utf8View.h b/AK/Utf8View.h index f03dc682a29..5270addd4a9 100644 --- a/AK/Utf8View.h +++ b/AK/Utf8View.h @@ -61,7 +61,7 @@ private: class Utf8View { public: - typedef Utf8CodepointIterator Iterator; + using Iterator = Utf8CodepointIterator; Utf8View() { } explicit Utf8View(const String&);