From 68f76b9e3750c8f4e5e3ee8c3d346772ce6d3593 Mon Sep 17 00:00:00 2001 From: Lenny Maiorani Date: Thu, 20 May 2021 17:27:29 -0600 Subject: [PATCH] Userland: Change typedef to using directive Problem: - `typedef`s are read backwards making it confusing. - `using` statements can be used in template aliases. - `using` provides similarity to most other C++ syntax. - C++ core guidelines say to prefer `using` over `typedef`: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rt-using Solution: - Switch these where appropriate. --- Userland/Applications/Piano/Track.h | 2 +- Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h | 3 +-- Userland/DevTools/HackStudio/Git/GitFilesView.h | 2 +- Userland/DevTools/HackStudio/Git/GitWidget.h | 2 +- Userland/DevTools/StateMachineGenerator/main.cpp | 2 +- Userland/Utilities/ntpquery.cpp | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Userland/Applications/Piano/Track.h b/Userland/Applications/Piano/Track.h index 6c660e37fc..d6a2abfb1c 100644 --- a/Userland/Applications/Piano/Track.h +++ b/Userland/Applications/Piano/Track.h @@ -13,7 +13,7 @@ #include #include -typedef AK::SinglyLinkedListIterator, RollNote> RollIter; +using RollIter = AK::SinglyLinkedListIterator, RollNote>; class Track { AK_MAKE_NONCOPYABLE(Track); diff --git a/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h b/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h index a1cbb8b055..45a3207c08 100644 --- a/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h +++ b/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h @@ -17,6 +17,5 @@ enum class BreakpointChange { Removed, }; -typedef Function BreakpointChangeCallback; - +using BreakpointChangeCallback = Function; } diff --git a/Userland/DevTools/HackStudio/Git/GitFilesView.h b/Userland/DevTools/HackStudio/Git/GitFilesView.h index 83df71e95b..0901e4787e 100644 --- a/Userland/DevTools/HackStudio/Git/GitFilesView.h +++ b/Userland/DevTools/HackStudio/Git/GitFilesView.h @@ -13,7 +13,7 @@ namespace HackStudio { // A "GitFileAction" is either the staging or the unstaging of a file. -typedef Function GitFileActionCallback; +using GitFileActionCallback = Function; class GitFilesView : public GUI::ListView { C_OBJECT(GitFilesView) diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.h b/Userland/DevTools/HackStudio/Git/GitWidget.h index 608acea3fc..7bb852022b 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.h +++ b/Userland/DevTools/HackStudio/Git/GitWidget.h @@ -14,7 +14,7 @@ namespace HackStudio { -typedef Function ViewDiffCallback; +using ViewDiffCallback = Function; class GitWidget final : public GUI::Widget { C_OBJECT(GitWidget) diff --git a/Userland/DevTools/StateMachineGenerator/main.cpp b/Userland/DevTools/StateMachineGenerator/main.cpp index c0a6321c1d..9e82e75399 100644 --- a/Userland/DevTools/StateMachineGenerator/main.cpp +++ b/Userland/DevTools/StateMachineGenerator/main.cpp @@ -332,7 +332,7 @@ public: generator.append(R"~~~( }; // end Action - typedef Function Handler; + using Handler = Function; @class_name@(Handler handler) : m_handler(move(handler)) diff --git a/Userland/Utilities/ntpquery.cpp b/Userland/Utilities/ntpquery.cpp index c5abba8523..a4ead4e42b 100644 --- a/Userland/Utilities/ntpquery.cpp +++ b/Userland/Utilities/ntpquery.cpp @@ -25,7 +25,7 @@ // An NtpTimestamp is a 64-bit integer that's a 32.32 binary-fixed point number. // The integral part in the upper 32 bits represents seconds since 1900-01-01. // The fractional part in the lower 32 bits stores fractional bits times 2 ** 32. -typedef uint64_t NtpTimestamp; +using NtpTimestamp = uint64_t; struct [[gnu::packed]] NtpPacket { uint8_t li_vn_mode;