diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-03-06 22:56:56 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-03-06 22:56:56 +0100 |
commit | f0cccbe3285c039553e1fd8b5a5c7830d6087974 (patch) | |
tree | 57a0902484ec5c8ba3b9a8e7089ed42f58b6a580 /asl/types | |
parent | 54affafd86e2b7f387345c08e8c7285c775d75e5 (diff) |
Replace ASL_MOVE, ASL_FWD, and ASL_FWD_LIKE by their std:: equivalent
This is because some compiler stuff and diagnostics tools rely on those
symboles being what they are.
Diffstat (limited to 'asl/types')
-rw-r--r-- | asl/types/box.hpp | 22 | ||||
-rw-r--r-- | asl/types/box_tests.cpp | 6 | ||||
-rw-r--r-- | asl/types/maybe_uninit.hpp | 12 | ||||
-rw-r--r-- | asl/types/option.hpp | 56 | ||||
-rw-r--r-- | asl/types/option_tests.cpp | 12 | ||||
-rw-r--r-- | asl/types/status.cpp | 4 | ||||
-rw-r--r-- | asl/types/status.hpp | 8 | ||||
-rw-r--r-- | asl/types/status_or.hpp | 26 | ||||
-rw-r--r-- | asl/types/status_or_tests.cpp | 4 |
9 files changed, 75 insertions, 75 deletions
diff --git a/asl/types/box.hpp b/asl/types/box.hpp index 4b6e0b3..6501e3e 100644 --- a/asl/types/box.hpp +++ b/asl/types/box.hpp @@ -29,21 +29,21 @@ public: constexpr box(T* ptr, Allocator alloc) : m_ptr{ptr} - , m_alloc{ASL_MOVE(alloc)} + , m_alloc{std::move(alloc)} { ASL_ASSERT(m_ptr != nullptr); } constexpr box(box&& other) : m_ptr{exchange(other.m_ptr, nullptr)} - , m_alloc{ASL_MOVE(other.m_alloc)} + , m_alloc{std::move(other.m_alloc)} {} template<is_object U> requires convertible_from<T*, U*> - constexpr box(box<U, Allocator>&& other) // NOLINT(*-explicit-conversions) + constexpr box(box<U, Allocator>&& other) // NOLINT(*explicit*,*-not-moved) : m_ptr{exchange(other.m_ptr, nullptr)} - , m_alloc{ASL_MOVE(other.m_alloc)} + , m_alloc{std::move(other.m_alloc)} {} constexpr box& operator=(box&& other) @@ -53,7 +53,7 @@ public: if (m_ptr != nullptr) { reset(); } m_ptr = exchange(other.m_ptr, nullptr); - m_alloc = ASL_MOVE(other.m_alloc); + m_alloc = std::move(other.m_alloc); return *this; } @@ -99,7 +99,7 @@ public: requires hashable<T> friend H AslHashValue(H h, const box& b) { - return H::combine(ASL_MOVE(h), *b); + return H::combine(std::move(h), *b); } template<is_object U, allocator A> @@ -114,8 +114,8 @@ constexpr box<T, Allocator> make_box_in(Allocator allocator, Args&&... args) requires constructible_from<T, Args&&...> { void* raw_ptr = allocator.alloc(layout::of<T>()); - auto* ptr = construct_at<T>(raw_ptr, ASL_FWD(args)...); - return box(ptr, ASL_MOVE(allocator)); + auto* ptr = construct_at<T>(raw_ptr, std::forward<Args>(args)...); + return box(ptr, std::move(allocator)); } template<is_object T, allocator Allocator = DefaultAllocator, typename... Args> @@ -124,14 +124,14 @@ constexpr box<T, Allocator> make_box(Args&&... args) { Allocator allocator{}; void* raw_ptr = allocator.alloc(layout::of<T>()); - auto* ptr = construct_at<T>(raw_ptr, ASL_FWD(args)...); - return box<T>(ptr, ASL_MOVE(allocator)); + auto* ptr = construct_at<T>(raw_ptr, std::forward<Args>(args)...); + return box<T>(ptr, std::move(allocator)); } template<is_object T, allocator A> constexpr T* leak(box<T, A>&& b) { - return exchange(b.m_ptr, nullptr); + return exchange(std::move(b).m_ptr, nullptr); } } // namespace asl diff --git a/asl/types/box_tests.cpp b/asl/types/box_tests.cpp index 210943c..d7281ed 100644 --- a/asl/types/box_tests.cpp +++ b/asl/types/box_tests.cpp @@ -23,7 +23,7 @@ ASL_TEST(destructor) ASL_TEST_ASSERT(!d); - auto box3 = ASL_MOVE(box); + auto box3 = std::move(box); ASL_TEST_ASSERT(!d); } @@ -35,7 +35,7 @@ ASL_TEST(value) auto b = asl::make_box<int>(24); ASL_TEST_EXPECT(*b == 24); - auto b2 = ASL_MOVE(b); + auto b2 = std::move(b); ASL_TEST_EXPECT(*b2 == 24); } @@ -44,7 +44,7 @@ ASL_TEST(ptr) auto b = asl::make_box<int>(24); auto* ptr1 = b.get(); - auto b2 = ASL_MOVE(b); + auto b2 = std::move(b); auto* ptr2 = b2.get(); ASL_TEST_EXPECT(ptr1 == ptr2); } diff --git a/asl/types/maybe_uninit.hpp b/asl/types/maybe_uninit.hpp index a0d6b86..3b2f755 100644 --- a/asl/types/maybe_uninit.hpp +++ b/asl/types/maybe_uninit.hpp @@ -23,7 +23,7 @@ public: explicit constexpr maybe_uninit(in_place_t, auto&&... args) requires constructible_from<T, decltype(args)...> - : m_value{ASL_FWD(args)...} + : m_value{std::forward<decltype(args)>(args)...} {} constexpr maybe_uninit(const maybe_uninit&) requires trivially_copy_constructible<T> = default; @@ -33,10 +33,10 @@ public: constexpr maybe_uninit(maybe_uninit&&) requires (!trivially_move_constructible<T>) {} // NOLINT constexpr maybe_uninit& operator=(const maybe_uninit&) requires trivially_copy_assignable<T> = default; - constexpr maybe_uninit& operator=(const maybe_uninit&) requires (!trivially_copy_assignable<T>) {} + constexpr maybe_uninit& operator=(const maybe_uninit&) requires (!trivially_copy_assignable<T>) { return *this; } // NOLINT constexpr maybe_uninit& operator=(maybe_uninit&&) requires trivially_move_assignable<T> = default; - constexpr maybe_uninit& operator=(maybe_uninit&&) requires (!trivially_move_assignable<T>) {} + constexpr maybe_uninit& operator=(maybe_uninit&&) requires (!trivially_move_assignable<T>) { return *this; } // NOLINT constexpr ~maybe_uninit() requires trivially_destructible<T> = default; constexpr ~maybe_uninit() requires (!trivially_destructible<T>) {} // NOLINT @@ -45,14 +45,14 @@ public: constexpr void construct_unsafe(auto&&... args) requires constructible_from<T, decltype(args)...> { - construct_at<T>(&m_value, ASL_FWD(args)...); + construct_at<T>(&m_value, std::forward<decltype(args)>(args)...); } // @Safety Value must have been initialized constexpr void assign_unsafe(auto&& value) requires assignable_from<T&, decltype(value)> { - m_value = ASL_FWD(value); + m_value = std::forward<decltype(value)>(value); } // @Safety Value must have been initialized @@ -67,7 +67,7 @@ public: // @Safety Value must have been initialized constexpr auto&& as_init_unsafe(this auto&& self) { - return ASL_FWD(self).m_value; + return std::forward<decltype(self)>(self).m_value; } }; diff --git a/asl/types/option.hpp b/asl/types/option.hpp index c25d12d..9c317b0 100644 --- a/asl/types/option.hpp +++ b/asl/types/option.hpp @@ -74,19 +74,19 @@ class option if constexpr (!kHasNiche) { - m_payload.construct_unsafe(ASL_FWD(args)...); + m_payload.construct_unsafe(std::forward<Args>(args)...); m_has_value = true; } else { if constexpr (move_assignable<T>) { - m_payload.assign_unsafe(ASL_MOVE(T{ASL_FWD(args)...})); + m_payload.assign_unsafe(T{std::forward<Args>(args)...}); } else { m_payload.destroy_unsafe(); - m_payload.construct_unsafe(ASL_FWD(args)...); + m_payload.construct_unsafe(std::forward<Args>(args)...); } } } @@ -95,7 +95,7 @@ class option constexpr void assign(U&& arg) { ASL_ASSERT(has_value()); - m_payload.assign_unsafe(ASL_FWD(arg)); + m_payload.assign_unsafe(std::forward<U>(arg)); } public: @@ -103,10 +103,10 @@ public: constexpr option() : option{nullopt} {} - // NOLINTNEXTLINE(*-explicit-conversions) + // NOLINTNEXTLINE(*explicit*) constexpr option(nullopt_t) requires (!kHasNiche) {} - // NOLINTNEXTLINE(*-explicit-conversions) + // NOLINTNEXTLINE(*explicit*) constexpr option(nullopt_t) requires kHasNiche : m_payload{in_place, niche_t{}} {} template<typename U = T> @@ -117,7 +117,7 @@ public: constructible_from<T, U&&> && !same_as<un_cvref_t<U>, option> ) - : m_payload{in_place, ASL_FWD(value)} + : m_payload{in_place, std::forward<U>(value)} {} template<typename U = T> @@ -128,7 +128,7 @@ public: constructible_from<T, U&&> && !is_option<U> ) - : m_payload{in_place, ASL_FWD(value)} + : m_payload{in_place, std::forward<U>(value)} , m_has_value{true} {} @@ -154,7 +154,7 @@ public: { if (other.has_value()) { - construct(ASL_MOVE(other.m_payload.as_init_unsafe())); + construct(std::move(other.m_payload.as_init_unsafe())); } } @@ -184,7 +184,7 @@ public: { if (other.has_value()) { - construct(ASL_MOVE(other.m_payload.as_init_unsafe())); + construct(std::move(other).m_payload.as_init_unsafe()); } } @@ -204,11 +204,11 @@ public: { if (has_value()) { - assign(ASL_FWD(value)); + assign(std::forward<U>(value)); } else { - construct(ASL_FWD(value)); + construct(std::forward<U>(value)); } return *this; @@ -259,11 +259,11 @@ public: { if (has_value()) { - assign(ASL_MOVE(other.m_payload.as_init_unsafe())); + assign(std::move(other.m_payload.as_init_unsafe())); } else { - construct(ASL_MOVE(other.m_payload.as_init_unsafe())); + construct(std::move(other.m_payload.as_init_unsafe())); } } else if (has_value()) @@ -313,11 +313,11 @@ public: { if (has_value()) { - assign(ASL_MOVE(other.m_payload.as_init_unsafe())); + assign(std::move(other).m_payload.as_init_unsafe()); } else { - construct(ASL_MOVE(other.m_payload.as_init_unsafe())); + construct(std::move(other).m_payload.as_init_unsafe()); } } else if (has_value()) @@ -342,7 +342,7 @@ public: { if constexpr (move_assignable<T>) { - m_payload.assign_unsafe(ASL_MOVE(T{niche_t{}})); + m_payload.assign_unsafe(std::move(T{niche_t{}})); } else { @@ -357,7 +357,7 @@ public: } } - constexpr bool has_value() const + [[nodiscard]] constexpr bool has_value() const { if constexpr (kHasNiche) { @@ -372,28 +372,28 @@ public: constexpr auto&& value(this auto&& self) { ASL_ASSERT_RELEASE(self.has_value()); - return ASL_FWD(self).m_payload.as_init_unsafe(); + return std::forward<decltype(self)>(self).m_payload.as_init_unsafe(); } template<typename U> constexpr T value_or(U&& other_value) const& requires copy_constructible<T> && convertible_from<T, U&&> { - return has_value() ? value() : static_cast<T>(ASL_FWD(other_value)); + return has_value() ? value() : static_cast<T>(std::forward<U>(other_value)); } template<typename U> constexpr T value_or(U&& other_value) && requires move_constructible<T> && convertible_from<T, U&&> { - return has_value() ? ASL_MOVE(value()) : static_cast<T>(ASL_FWD(other_value)); + return has_value() ? std::move(value()) : static_cast<T>(std::forward<U>(other_value)); } constexpr T& emplace(auto&&... args) & requires constructible_from<T, decltype(args)...> { if (has_value()) { reset(); } - construct(ASL_FWD(args)...); + construct(std::forward<decltype(args)>(args)...); return value(); } @@ -405,7 +405,7 @@ public: if (self.has_value()) { - return invoke(ASL_FWD(f), ASL_FWD(self).value()); + return invoke(std::forward<F>(f), std::forward<decltype(self)>(self).value()); } return Result{ asl::nullopt }; } @@ -417,7 +417,7 @@ public: if (self.has_value()) { return option<un_cvref_t<Result>>{ - invoke(ASL_FWD(f), ASL_FWD(self).value()) + invoke(std::forward<F>(f), std::forward<decltype(self)>(self).value()) }; } return option<un_cvref_t<Result>>{ asl::nullopt }; @@ -427,14 +427,14 @@ public: constexpr option or_else(F&& f) const& requires same_as<un_cvref_t<invoke_result_t<F>>, option> { - return has_value() ? *this : invoke(ASL_FWD(f)); + return has_value() ? *this : invoke(std::forward<F>(f)); } template<typename F> constexpr option or_else(F&& f) && requires same_as<un_cvref_t<invoke_result_t<F>>, option> { - return has_value() ? ASL_MOVE(*this) : invoke(ASL_FWD(f)); + return has_value() ? std::move(*this) : invoke(std::forward<F>(f)); } template<typename H> @@ -443,9 +443,9 @@ public: { if (!opt.has_value()) { - return H::combine(ASL_MOVE(h), 0); + return H::combine(std::move(h), 0); } - return H::combine(ASL_MOVE(h), 1, opt.value()); + return H::combine(std::move(h), 1, opt.value()); } }; diff --git a/asl/types/option_tests.cpp b/asl/types/option_tests.cpp index 22b34d3..2dff6f5 100644 --- a/asl/types/option_tests.cpp +++ b/asl/types/option_tests.cpp @@ -129,10 +129,10 @@ ASL_TEST(call_destructor) { DestructorObserver obs(&destroyed); - asl::option<DestructorObserver> opt(ASL_MOVE(obs)); + asl::option<DestructorObserver> opt(std::move(obs)); ASL_TEST_EXPECT(!destroyed); - asl::option<DestructorObserver> opt2 = ASL_MOVE(opt); + asl::option<DestructorObserver> opt2 = std::move(opt); ASL_TEST_EXPECT(!destroyed); } @@ -172,7 +172,7 @@ ASL_TEST(value_move) ASL_TEST_EXPECT(!destroyed); { - auto x = ASL_MOVE(opt).value(); + auto x = std::move(opt).value(); ASL_TEST_EXPECT(!destroyed); } @@ -208,19 +208,19 @@ ASL_TEST(convert_copy) ASL_TEST(convert_move) { asl::option<uint8_t> opt8 = uint8_t{8}; - asl::option<uint16_t> opt16 = ASL_MOVE(opt8); + asl::option<uint16_t> opt16 = std::move(opt8); ASL_TEST_ASSERT(opt16.has_value()); ASL_TEST_EXPECT(opt16.value() == 8); - opt8 = ASL_MOVE(uint8_t{10}); + opt8 = std::move(uint8_t{10}); ASL_TEST_ASSERT(opt8.has_value()); ASL_TEST_EXPECT(opt8.value() == 10); opt16 = asl::nullopt; ASL_TEST_EXPECT(!opt16.has_value()); - opt16 = ASL_MOVE(opt8); + opt16 = std::move(opt8); ASL_TEST_ASSERT(opt16.has_value()); ASL_TEST_EXPECT(opt16.value() == 10); } diff --git a/asl/types/status.cpp b/asl/types/status.cpp index fd751d1..94c4977 100644 --- a/asl/types/status.cpp +++ b/asl/types/status.cpp @@ -23,7 +23,7 @@ struct StatusInternal asl::atomic<int32_t> ref_count; constexpr StatusInternal(asl::string<Allocator>&& msg_, asl::status_code code_) - : msg{ASL_MOVE(msg_)} + : msg{std::move(msg_)} , code{code_} { ASL_ASSERT(code != asl::status_code::ok); @@ -41,7 +41,7 @@ asl::status::status(status_code code, string_view fmt, span<format_internals::ty { StringWriter<Allocator> sink{g_allocator}; format_internals::format(&sink, fmt, args); - m_payload = alloc_new<StatusInternal>(g_allocator, ASL_MOVE(sink).finish(), code); + m_payload = alloc_new<StatusInternal>(g_allocator, std::move(sink).finish(), code); } asl::status_code asl::status::code_internal() const diff --git a/asl/types/status.hpp b/asl/types/status.hpp index 31b6df6..83be5ce 100644 --- a/asl/types/status.hpp +++ b/asl/types/status.hpp @@ -122,7 +122,7 @@ public: return {}; } - constexpr status&& throw_status() && { return ASL_MOVE(*this); } + constexpr status&& throw_status() && { return std::move(*this); } friend void AslFormat(Formatter& f, const status&); @@ -131,9 +131,9 @@ public: { if (s.is_inline()) { - return H::combine(ASL_MOVE(h), s.code()); + return H::combine(std::move(h), s.code()); } - return H::combine(ASL_MOVE(h), s.code(), s.message()); + return H::combine(std::move(h), s.code(), s.message()); } }; @@ -156,6 +156,6 @@ ASL_DEFINE_ERROR_(internal) ASL_DEFINE_ERROR_(runtime) ASL_DEFINE_ERROR_(invalid_argument) -#define ASL_TRY(VALUE) if (VALUE.ok()) {} else { return ASL_MOVE(VALUE).throw_status(); } +#define ASL_TRY(VALUE) if (VALUE.ok()) {} else { return std::move(VALUE).throw_status(); } } // namespace asl diff --git a/asl/types/status_or.hpp b/asl/types/status_or.hpp index c40ecce..be6bb06 100644 --- a/asl/types/status_or.hpp +++ b/asl/types/status_or.hpp @@ -33,11 +33,11 @@ public: constexpr status_or(status_or&& other) requires move_constructible<T> - : m_status{ASL_MOVE(other.m_status)} + : m_status{std::move(other.m_status)} { if (other.ok()) { - m_value.construct_unsafe(ASL_MOVE(other.m_value.as_init_unsafe())); + m_value.construct_unsafe(std::move(other.m_value.as_init_unsafe())); } } @@ -75,7 +75,7 @@ public: { if (other.ok()) { - m_value.assign_unsafe(ASL_MOVE(other.m_value.as_init_unsafe())); + m_value.assign_unsafe(std::move(other.m_value.as_init_unsafe())); } else { @@ -84,9 +84,9 @@ public: } else if (other.ok()) { - m_value.construct_unsafe(ASL_MOVE(other.m_value.as_init_unsafe())); + m_value.construct_unsafe(std::move(other.m_value.as_init_unsafe())); } - m_status = ASL_MOVE(other.m_status); + m_status = std::move(other.m_status); } return *this; } @@ -106,7 +106,7 @@ public: } // NOLINTNEXTLINE(*-explicit-conversions) - constexpr status_or(status&& status) : m_status{ASL_MOVE(status)} + constexpr status_or(status&& status) : m_status{std::move(status)} { ASL_ASSERT_RELEASE(!m_status.ok()); } @@ -122,7 +122,7 @@ public: !same_as<un_cvref_t<U>, status> ) : m_status{status_code::ok} - , m_value{in_place, ASL_FWD(value)} + , m_value{in_place, std::forward<U>(value)} {} constexpr bool ok() const { return m_status.ok(); } @@ -131,26 +131,26 @@ public: constexpr string_view message() const { return m_status.message(); } - constexpr status&& throw_status() && { return ASL_MOVE(m_status); } + constexpr status&& throw_status() && { return std::move(m_status); } constexpr auto&& value(this auto&& self) { ASL_ASSERT_RELEASE(self.ok()); - return ASL_FWD(self).m_value.as_init_unsafe(); + return std::forward<decltype(self)>(self).m_value.as_init_unsafe(); } template<typename U> constexpr T value_or(U&& other_value) const& requires copy_constructible<T> && convertible_from<T, U&&> { - return ok() ? value() : static_cast<T>(ASL_FWD(other_value)); + return ok() ? value() : static_cast<T>(std::forward<U>(other_value)); } template<typename U> constexpr T value_or(U&& other_value) && requires move_constructible<T> && convertible_from<T, U&&> { - return ok() ? ASL_MOVE(value()) : static_cast<T>(ASL_FWD(other_value)); + return ok() ? std::move(value()) : static_cast<T>(std::forward<U>(other_value)); } friend void AslFormat(Formatter& f, const status_or& status) @@ -164,9 +164,9 @@ public: { if (s.ok()) { - return H::combine(ASL_MOVE(h), s.m_status, s.value()); + return H::combine(std::move(h), s.m_status, s.value()); } - return H::combine(ASL_MOVE(h), s.m_status); + return H::combine(std::move(h), s.m_status); } }; diff --git a/asl/types/status_or_tests.cpp b/asl/types/status_or_tests.cpp index 464b8bb..08b4a0f 100644 --- a/asl/types/status_or_tests.cpp +++ b/asl/types/status_or_tests.cpp @@ -52,11 +52,11 @@ ASL_TEST(destructor) ASL_TEST_EXPECT(s.ok()); ASL_TEST_EXPECT(!d); - asl::status_or s2 = ASL_MOVE(s); + asl::status_or s2 = std::move(s); ASL_TEST_EXPECT(s.ok()); ASL_TEST_EXPECT(!d); - s = ASL_MOVE(s2); + s = std::move(s2); ASL_TEST_EXPECT(s.ok()); ASL_TEST_EXPECT(!d); } |