From edc3ed2a0ed4060460d86a144efbdbdc3c237a2e Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 24 Aug 2022 10:48:44 +0100 Subject: [PATCH] AK: Allow creating NonnullPtrVectors from an initializer list This was present in Vector already. Clang-format fixed some const positions automatically too. Also removed a now-ambiguous and unnecessary constructor from Shell. --- AK/NonnullPtrVector.h | 14 +++++++++----- Userland/Shell/AST.h | 4 ---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/AK/NonnullPtrVector.h b/AK/NonnullPtrVector.h index 6471dd3586..d78dcfab7e 100644 --- a/AK/NonnullPtrVector.h +++ b/AK/NonnullPtrVector.h @@ -26,10 +26,14 @@ public: : Base(static_cast(other)) { } + NonnullPtrVector(std::initializer_list list) + : Base(list) + { + } using Base::size; - using ConstIterator = SimpleIterator; + using ConstIterator = SimpleIterator; using Iterator = SimpleIterator; using ReverseIterator = SimpleReverseIterator; using ReverseConstIterator = SimpleReverseIterator; @@ -60,13 +64,13 @@ public: ALWAYS_INLINE PtrType const& ptr_at(size_t index) const { return Base::at(index); } ALWAYS_INLINE T& at(size_t index) { return *Base::at(index); } - ALWAYS_INLINE const T& at(size_t index) const { return *Base::at(index); } + ALWAYS_INLINE T const& at(size_t index) const { return *Base::at(index); } ALWAYS_INLINE T& operator[](size_t index) { return at(index); } - ALWAYS_INLINE const T& operator[](size_t index) const { return at(index); } + ALWAYS_INLINE T const& operator[](size_t index) const { return at(index); } ALWAYS_INLINE T& first() { return at(0); } - ALWAYS_INLINE const T& first() const { return at(0); } + ALWAYS_INLINE T const& first() const { return at(0); } ALWAYS_INLINE T& last() { return at(size() - 1); } - ALWAYS_INLINE const T& last() const { return at(size() - 1); } + ALWAYS_INLINE T const& last() const { return at(size() - 1); } private: // NOTE: You can't use resize() on a NonnullFooPtrVector since making the vector diff --git a/Userland/Shell/AST.h b/Userland/Shell/AST.h index d363234cd9..60cdfd0dbb 100644 --- a/Userland/Shell/AST.h +++ b/Userland/Shell/AST.h @@ -306,10 +306,6 @@ public: virtual bool is_list() const override { return true; } virtual bool is_list_without_resolution() const override { return true; } ListValue(Vector values); - ListValue(Vector> values) - : m_contained_values(move(static_cast&>(values))) - { - } ListValue(NonnullRefPtrVector values) : m_contained_values(move(values)) {