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.
This commit is contained in:
2025-03-06 22:56:56 +01:00
parent 54affafd86
commit f0cccbe328
32 changed files with 293 additions and 245 deletions

View File

@ -1,34 +1,15 @@
Checks: Checks:
- "hicpp-*" - "*"
- "cppcoreguidelines-*" - "-llvm*"
- "misc-*" - "-altera*"
- "clang-analyzer-*" - "-fuchsia*"
- "-misc-include-cleaner" - "-*-use-trailing-return-type"
- "performance-*" - "-readability-identifier-length"
- "readability-*" - "-cppcoreguidelines-macro-usage"
- "-*-named-parameter"
- "-*-avoid-do-while"
- "-*-magic-numbers"
- "-*-identifier-length"
- "-*-union-access"
- "-*-vararg"
- "-*-macro-usage"
- "-*-non-private-member-variables-in-classes"
- "-*-avoid-non-const-global-variables"
- "-*-missing-std-forward"
- "-*-owning-memory"
- "-*-no-malloc"
- "-*-avoid-c-arrays" - "-*-avoid-c-arrays"
- "-*-non-private-member-variables-in-classes"
- "-*-use-anonymous-namespace" - "-*-use-anonymous-namespace"
- "-*-reinterpret-cast" - "-cert-err58-cpp"
- "-*-noexcept-swap" - "-*noexcept*"
- "-*-noexcept-move" - "-*-magic-numbers"
- "-*-noexcept-move-constructor" - "-*-named-parameter"
- "-*-noexcept-move-operations"
- "-*-bounds-array-to-pointer-decay"
- "-*-no-array-decay"
- "-*-signed-bitwise"
- "-readability-use-anyofallof"
- "-readability-function-cognitive-complexity"
- "-readability-math-missing-parentheses"
- "-*-rvalue-reference-param-not-moved"

7
.clangd Normal file
View File

@ -0,0 +1,7 @@
---
CompilerFlags:
Add:
- "-Wall"
Diagnostics:
ClangTidy:
FastCheckFilter: None

View File

@ -4,7 +4,12 @@
#include "asl/base/assert.hpp" #include "asl/base/assert.hpp"
#include "asl/base/meta.hpp"
// NOLINTNEXTLINE(*-non-const-global-variables)
static asl::AssertFailureHandler* s_handler = nullptr; static asl::AssertFailureHandler* s_handler = nullptr;
// NOLINTNEXTLINE(*-non-const-global-variables)
static void* s_user = nullptr; static void* s_user = nullptr;
void asl::set_assert_failure_handler(AssertFailureHandler handler, void* user) void asl::set_assert_failure_handler(AssertFailureHandler handler, void* user)

View File

@ -18,14 +18,14 @@ class DeferCallback
public: public:
template<typename T> template<typename T>
explicit DeferCallback(T&& callback) : m_callback(ASL_FWD(callback)) explicit DeferCallback(T&& callback) : m_callback(std::forward<T>(callback))
{ {
} }
ASL_DELETE_COPY(DeferCallback); ASL_DELETE_COPY(DeferCallback);
DeferCallback(DeferCallback&& other) : DeferCallback(DeferCallback&& other) :
m_callback(ASL_MOVE(other.m_callback)), m_moved(exchange(other.m_moved, true)) m_callback(std::move(other.m_callback)), m_moved(exchange(other.m_moved, true))
{ {
} }
@ -42,7 +42,7 @@ struct DeferFactory
template<invocable Callback> template<invocable Callback>
DeferCallback<Callback> operator<<(Callback&& callback) const DeferCallback<Callback> operator<<(Callback&& callback) const
{ {
return DeferCallback<Callback>(ASL_FWD(callback)); return DeferCallback<Callback>(std::forward<Callback>(callback));
} }
}; };

View File

@ -11,22 +11,22 @@ namespace asl {
template<typename... Args, typename C> template<typename... Args, typename C>
constexpr auto invoke(is_func auto C::* f, auto&& self, Args&&... args) constexpr auto invoke(is_func auto C::* f, auto&& self, Args&&... args)
-> decltype((self.*f)(ASL_FWD(args)...)) -> decltype((self.*f)(std::forward<Args>(args)...))
requires requires { requires requires {
(self.*f)(ASL_FWD(args)...); (self.*f)(std::forward<Args>(args)...);
} }
{ {
return (ASL_FWD(self).*f)(ASL_FWD(args)...); return (std::forward<decltype(self)>(self).*f)(std::forward<Args>(args)...);
} }
template<typename... Args, typename C> template<typename... Args, typename C>
constexpr auto invoke(is_func auto C::* f, auto* self, Args&&... args) constexpr auto invoke(is_func auto C::* f, auto* self, Args&&... args)
-> decltype((self->*f)(ASL_FWD(args)...)) -> decltype((self->*f)(std::forward<Args>(args)...))
requires requires { requires requires {
(self->*f)(ASL_FWD(args)...); (self->*f)(std::forward<Args>(args)...);
} }
{ {
return (self->*f)(ASL_FWD(args)...); return (self->*f)(std::forward<Args>(args)...);
} }
template<typename... Args, typename C> template<typename... Args, typename C>
@ -37,7 +37,7 @@ constexpr auto invoke(is_object auto C::* m, auto&& self, Args&&...)
requires { self.*m; } requires { self.*m; }
) )
{ {
return ASL_FWD(self).*m; return std::forward<decltype(self)>(self).*m;
} }
template<typename... Args, typename C> template<typename... Args, typename C>
@ -53,12 +53,12 @@ constexpr auto invoke(is_object auto C::* m, auto* self, Args&&...)
template<typename... Args> template<typename... Args>
constexpr auto invoke(auto&& f, Args&&... args) constexpr auto invoke(auto&& f, Args&&... args)
-> decltype(f(ASL_FWD(args)...)) -> decltype(f(std::forward<Args>(args)...))
requires requires { requires requires {
f(ASL_FWD(args)...); f(std::forward<Args>(args)...);
} }
{ {
return ASL_FWD(f)(ASL_FWD(args)...); return std::forward<decltype(f)>(f)(std::forward<Args>(args)...);
} }
template<typename Void, typename F, typename... Args> template<typename Void, typename F, typename... Args>
@ -76,7 +76,7 @@ using invoke_result_t = _invoke_result_helper<void, F, Args...>::type;
template<typename F, typename... Args> template<typename F, typename... Args>
concept invocable = requires (F&& f, Args&&... args) concept invocable = requires (F&& f, Args&&... args)
{ {
invoke(ASL_FWD(f), ASL_FWD(args)...); invoke(std::forward<F>(f), std::forward<Args>(args)...);
}; };
} // namespace asl } // namespace asl

View File

@ -7,11 +7,36 @@
#include "asl/base/meta.hpp" #include "asl/base/meta.hpp"
#include "asl/base/assert.hpp" #include "asl/base/assert.hpp"
#define ASL_MOVE(...) (static_cast<::asl::un_ref_t<decltype(__VA_ARGS__)>&&>(__VA_ARGS__)) namespace std
{
#define ASL_FWD(expr_) (static_cast<decltype(expr_)&&>(expr_)) template<typename T>
constexpr asl::un_ref_t<T>&& move(T&& t) noexcept // NOLINT
{
return static_cast<asl::un_ref_t<T>&&>(t);
}
template<typename T>
constexpr T&& forward(asl::un_ref_t<T>& t) noexcept // NOLINT
{
return static_cast<T&&>(t);
}
template< class T >
constexpr T&& forward(asl::un_ref_t<T>&& t) noexcept // NOLINT
{
return static_cast<T&&>(t);
}
template<typename T, typename U>
constexpr auto forward_like(U&& x) noexcept -> asl::copy_cref_t<T, U> // NOLINT
{
using return_type = asl::copy_cref_t<T, U&&>;
return static_cast<return_type>(x);
}
} // namespace std
#define ASL_FWD_LIKE(ref_, expr_) (static_cast<::asl::copy_cref_t<ref_, decltype(expr_)&&>>(expr_))
namespace asl namespace asl
{ {
@ -22,16 +47,16 @@ static constexpr in_place_t in_place{};
template<moveable T> template<moveable T>
constexpr void swap(T& a, T& b) constexpr void swap(T& a, T& b)
{ {
T tmp{ASL_MOVE(a)}; T tmp{std::move(a)};
a = ASL_MOVE(b); a = std::move(b);
b = ASL_MOVE(tmp); b = std::move(tmp);
} }
template<typename T, typename U> template<typename T, typename U>
T exchange(T& obj, U&& new_value) T exchange(T& obj, U&& new_value)
{ {
T old_value = ASL_MOVE(obj); T old_value = std::move(obj);
obj = ASL_FWD(new_value); obj = std::forward<U>(new_value);
return old_value; return old_value;
} }
@ -59,44 +84,46 @@ constexpr uint64_t round_up_pow2(uint64_t v)
v -= 1; v -= 1;
v |= v >> 1; v |= v >> 1U;
v |= v >> 2; v |= v >> 2U;
v |= v >> 4; v |= v >> 4U;
v |= v >> 8; v |= v >> 8U;
v |= v >> 16; v |= v >> 16U;
v |= v >> 32; v |= v >> 32U;
return v + 1; return v + 1;
} }
constexpr bool is_pow2(isize_t v) constexpr bool is_pow2(isize_t v)
{ {
return v > 0 && ((v - 1) & v) == 0; return v > 0 && ((v - 1) & v) == 0; // NOLINT
} }
// NOLINTBEGIN(*-macro-parentheses)
#define ASL_DELETE_COPY(T) \ #define ASL_DELETE_COPY(T) \
T(const T&) = delete; \ T(const T&) = delete; \
T& operator=(const T&) = delete; T& operator=(const T&) = delete
#define ASL_DELETE_MOVE(T) \ #define ASL_DELETE_MOVE(T) \
T(T&&) = delete; \ T(T&&) = delete; \
T& operator=(T&&) = delete; T& operator=(T&&) = delete
#define ASL_DELETE_COPY_MOVE(T) \ #define ASL_DELETE_COPY_MOVE(T) \
ASL_DELETE_COPY(T) \ ASL_DELETE_COPY(T); \
ASL_DELETE_MOVE(T) ASL_DELETE_MOVE(T)
#define ASL_DEFAULT_COPY(T) \ #define ASL_DEFAULT_COPY(T) \
T(const T&) = default; \ T(const T&) = default; \
T& operator=(const T&) = default; T& operator=(const T&) = default
#define ASL_DEFAULT_MOVE(T) \ #define ASL_DEFAULT_MOVE(T) \
T(T&&) = default; \ T(T&&) = default; \
T& operator=(T&&) = default; T& operator=(T&&) = default
#define ASL_DEFAULT_COPY_MOVE(T) \ #define ASL_DEFAULT_COPY_MOVE(T) \
ASL_DEFAULT_COPY(T) \ ASL_DEFAULT_COPY(T); \
ASL_DEFAULT_MOVE(T) ASL_DEFAULT_MOVE(T)
// NOLINTEND(*-macro-parentheses)
#define ASL_CONCAT2(A, B) A##B #define ASL_CONCAT2(A, B) A##B
#define ASL_CONCAT(A, B) ASL_CONCAT2(A, B) #define ASL_CONCAT(A, B) ASL_CONCAT2(A, B)

View File

@ -12,28 +12,28 @@ template<typename T> static constexpr int identify(T&&) { return 4; }
struct IdentifySelf struct IdentifySelf
{ {
constexpr int get(this auto&& self) { return identify(ASL_FWD(self)); } constexpr int get(this auto&& self) { return identify(std::forward<decltype(self)>(self)); }
}; };
static int get_const_lref(const IdentifySelf& i) { return ASL_FWD(i).get(); } static int get_const_lref(const IdentifySelf& i) { return i.get(); }
static int get_const_rref(const IdentifySelf&& i) { return ASL_FWD(i).get(); } static int get_const_rref(const IdentifySelf&& i) { return std::move(i).get(); } // NOLINT
static int get_lref(IdentifySelf& i) { return ASL_FWD(i).get(); } static int get_lref(IdentifySelf& i) { return i.get(); }
static int get_rref(IdentifySelf&& i) { return ASL_FWD(i).get(); } static int get_rref(IdentifySelf&& i) { return std::move(i).get(); } // NOLINT
ASL_TEST(forward) ASL_TEST(forward)
{ {
IdentifySelf id; IdentifySelf id{};
ASL_TEST_EXPECT(get_const_lref(id) == 1); ASL_TEST_EXPECT(get_const_lref(IdentifySelf{}) == 1);
ASL_TEST_EXPECT(get_lref(id) == 3); ASL_TEST_EXPECT(get_lref(id) == 3);
ASL_TEST_EXPECT(get_const_rref(ASL_MOVE(id)) == 2); ASL_TEST_EXPECT(get_const_rref(IdentifySelf{}) == 2);
ASL_TEST_EXPECT(get_rref(ASL_MOVE(id)) == 4); ASL_TEST_EXPECT(get_rref(IdentifySelf{}) == 4);
} }
ASL_TEST(move) ASL_TEST(move)
{ {
IdentifySelf id; IdentifySelf id;
ASL_TEST_EXPECT(id.get() == 3); ASL_TEST_EXPECT(id.get() == 3);
ASL_TEST_EXPECT(ASL_MOVE(id).get() == 4); ASL_TEST_EXPECT(IdentifySelf{}.get() == 4);
} }
struct Level1 struct Level1
@ -51,33 +51,33 @@ struct Level3
Level2 deeper; Level2 deeper;
}; };
static int get_const_lref(const Level3& i) { return ASL_FWD(i).deeper.deeper.id.get(); } static int get_const_lref(const Level3& i) { return i.deeper.deeper.id.get(); }
static int get_const_rref(const Level3&& i) { return ASL_FWD(i).deeper.deeper.id.get(); } static int get_const_rref(const Level3&& i) { return std::move(i).deeper.deeper.id.get(); }
static int get_lref(Level3& i) { return ASL_FWD(i).deeper.deeper.id.get(); } static int get_lref(Level3& i) { return i.deeper.deeper.id.get(); }
static int get_rref(Level3&& i) { return ASL_FWD(i).deeper.deeper.id.get(); } static int get_rref(Level3&& i) { return std::move(i).deeper.deeper.id.get(); }
ASL_TEST(forward2) ASL_TEST(forward2)
{ {
Level3 id{}; Level3 id{};
ASL_TEST_EXPECT(get_const_lref(id) == 1); ASL_TEST_EXPECT(get_const_lref(id) == 1);
ASL_TEST_EXPECT(get_lref(id) == 3); ASL_TEST_EXPECT(get_lref(id) == 3);
ASL_TEST_EXPECT(get_const_rref(ASL_MOVE(id)) == 2); ASL_TEST_EXPECT(get_const_rref(Level3{}) == 2);
ASL_TEST_EXPECT(get_rref(ASL_MOVE(id)) == 4); ASL_TEST_EXPECT(get_rref(Level3{}) == 4);
} }
template<typename T> template<typename T>
static int test_fwd_like(T&& t) static int test_fwd_like(T) // NOLINT
{ {
IdentifySelf id; const IdentifySelf id;
return ASL_FWD_LIKE(decltype(t), id).get(); return std::forward_like<T>(id).get();
} }
ASL_TEST(forward_like) ASL_TEST(forward_like)
{ {
int x{}; int x{};
ASL_TEST_EXPECT(test_fwd_like<const int&>(x) == 1); ASL_TEST_EXPECT(test_fwd_like<const int&>(7) == 1);
ASL_TEST_EXPECT(test_fwd_like<int&>(x) == 3); ASL_TEST_EXPECT(test_fwd_like<int&>(x) == 3);
ASL_TEST_EXPECT(test_fwd_like<const int&&>(ASL_MOVE(x)) == 2); ASL_TEST_EXPECT(test_fwd_like<const int&&>(8) == 2);
ASL_TEST_EXPECT(test_fwd_like<int&&>(ASL_MOVE(x)) == 4); ASL_TEST_EXPECT(test_fwd_like<int&&>(9) == 4);
} }

View File

@ -170,7 +170,7 @@ private:
if (assign) if (assign)
{ {
m_allocator = ASL_MOVE(other.m_allocator); m_allocator = std::move(other.m_allocator);
} }
} }
@ -209,7 +209,7 @@ private:
// NOLINTNEXTLINE(*-pointer-arithmetic) // NOLINTNEXTLINE(*-pointer-arithmetic)
for (T* it = data_ptr + old_size; it < end; ++it) for (T* it = data_ptr + old_size; it < end; ++it)
{ {
construct_at<T>(it, ASL_FWD(args)...); construct_at<T>(it, std::forward<Args>(args)...);
} }
} }
@ -224,11 +224,11 @@ public:
} }
explicit constexpr buffer(Allocator allocator) explicit constexpr buffer(Allocator allocator)
: m_allocator{ASL_MOVE(allocator)} : m_allocator{std::move(allocator)}
{} {}
explicit constexpr buffer(span<const T> s, Allocator allocator) explicit constexpr buffer(span<const T> s, Allocator allocator)
: m_allocator{ASL_MOVE(allocator)} : m_allocator{std::move(allocator)}
{ {
copy_range(s); copy_range(s);
} }
@ -242,9 +242,9 @@ public:
constexpr buffer(buffer&& other) constexpr buffer(buffer&& other)
requires moveable<T> requires moveable<T>
: buffer(ASL_MOVE(other.m_allocator)) : buffer(std::move(other.m_allocator))
{ {
move_from_other(ASL_MOVE(other), false); move_from_other(std::move(other), false);
} }
constexpr buffer& operator=(const buffer& other) constexpr buffer& operator=(const buffer& other)
@ -259,7 +259,7 @@ public:
requires moveable<T> requires moveable<T>
{ {
if (&other == this) { return *this; } if (&other == this) { return *this; }
move_from_other(ASL_MOVE(other), true); move_from_other(std::move(other), true);
return *this; return *this;
} }
@ -381,7 +381,7 @@ public:
requires constructible_from<T, decltype(args)&&...> requires constructible_from<T, decltype(args)&&...>
{ {
T* uninit = push_uninit(); T* uninit = push_uninit();
T* init = construct_at<T>(uninit, ASL_FWD(args)...); T* init = construct_at<T>(uninit, std::forward<decltype(args)>(args)...);
return *init; return *init;
} }
@ -410,12 +410,12 @@ public:
return contiguous_iterator<type>{self.data() + self.size()}; return contiguous_iterator<type>{self.data() + self.size()};
} }
constexpr operator span<const T>() const // NOLINT(*-explicit-conversions) constexpr operator span<const T>() const // NOLINT(*explicit*)
{ {
return as_span(); return as_span();
} }
constexpr operator span<T>() // NOLINT(*-explicit-conversions) constexpr operator span<T>() // NOLINT(*explicit*)
{ {
return as_span(); return as_span();
} }
@ -429,14 +429,14 @@ public:
constexpr auto&& operator[](this auto&& self, isize_t i) constexpr auto&& operator[](this auto&& self, isize_t i)
{ {
ASL_ASSERT(i >= 0 && i <= self.size()); ASL_ASSERT(i >= 0 && i <= self.size());
return ASL_FWD_LIKE(decltype(self), ASL_FWD(self).data()[i]); return std::forward_like<decltype(self)>(std::forward<decltype(self)>(self).data()[i]);
} }
template<typename H> template<typename H>
requires hashable<T> requires hashable<T>
friend H AslHashValue(H h, const buffer& b) friend H AslHashValue(H h, const buffer& b)
{ {
return H::combine_contiguous(ASL_MOVE(h), b.as_span()); return H::combine_contiguous(std::move(h), b.as_span());
} }
}; };

View File

@ -275,7 +275,7 @@ ASL_TEST(move_construct_from_heap)
buf.push(&d[2]); buf.push(&d[2]);
{ {
asl::buffer<DestructorObserver> buf2(ASL_MOVE(buf)); asl::buffer<DestructorObserver> buf2(std::move(buf));
ASL_TEST_EXPECT(buf2.size() == 3); ASL_TEST_EXPECT(buf2.size() == 3);
ASL_TEST_EXPECT(d[0] == false); ASL_TEST_EXPECT(d[0] == false);
ASL_TEST_EXPECT(d[1] == false); ASL_TEST_EXPECT(d[1] == false);
@ -294,7 +294,7 @@ ASL_TEST(move_construct_inline_trivial)
buf.push(1U); buf.push(1U);
buf.push(2U); buf.push(2U);
asl::buffer<uint64_t> buf2(ASL_MOVE(buf)); asl::buffer<uint64_t> buf2(std::move(buf));
ASL_TEST_EXPECT(buf2[0] == 1U); ASL_TEST_EXPECT(buf2[0] == 1U);
ASL_TEST_EXPECT(buf2[1] == 2U); ASL_TEST_EXPECT(buf2[1] == 2U);
@ -310,7 +310,7 @@ ASL_TEST(move_construct_from_inline_non_trivial)
buf.push(&d[1]); buf.push(&d[1]);
{ {
asl::buffer<DestructorObserver> buf2(ASL_MOVE(buf)); asl::buffer<DestructorObserver> buf2(std::move(buf));
ASL_TEST_EXPECT(buf2.size() == 2); ASL_TEST_EXPECT(buf2.size() == 2);
ASL_TEST_EXPECT(d[0] == false); ASL_TEST_EXPECT(d[0] == false);
ASL_TEST_EXPECT(d[1] == false); ASL_TEST_EXPECT(d[1] == false);
@ -344,7 +344,7 @@ ASL_TEST(move_assign_from_heap)
ASL_TEST_EXPECT(d[4] == false); ASL_TEST_EXPECT(d[4] == false);
ASL_TEST_EXPECT(d[5] == false); ASL_TEST_EXPECT(d[5] == false);
buf2 = ASL_MOVE(buf); buf2 = std::move(buf);
ASL_TEST_EXPECT(buf.size() == 0); ASL_TEST_EXPECT(buf.size() == 0);
ASL_TEST_EXPECT(buf2.size() == 3); ASL_TEST_EXPECT(buf2.size() == 3);
@ -380,7 +380,7 @@ ASL_TEST(move_assign_trivial_heap_to_inline)
buf2.push(5); buf2.push(5);
ASL_TEST_EXPECT(alloc_count == 1); ASL_TEST_EXPECT(alloc_count == 1);
buf = ASL_MOVE(buf2); buf = std::move(buf2);
ASL_TEST_EXPECT(alloc_count == 1); ASL_TEST_EXPECT(alloc_count == 1);
ASL_TEST_EXPECT(buf.size() == 3); ASL_TEST_EXPECT(buf.size() == 3);
@ -405,7 +405,7 @@ ASL_TEST(move_assign_trivial_inline_to_heap)
buf2.push(5); buf2.push(5);
ASL_TEST_EXPECT(alloc_count == 1); ASL_TEST_EXPECT(alloc_count == 1);
buf2 = ASL_MOVE(buf); buf2 = std::move(buf);
ASL_TEST_EXPECT(alloc_count == 1); ASL_TEST_EXPECT(alloc_count == 1);
ASL_TEST_EXPECT(buf.size() == 0); ASL_TEST_EXPECT(buf.size() == 0);
@ -430,7 +430,7 @@ ASL_TEST(move_assign_inline_to_heap)
buf2.push(&d[4]); buf2.push(&d[4]);
buf2.push(&d[5]); buf2.push(&d[5]);
buf2 = ASL_MOVE(buf); buf2 = std::move(buf);
ASL_TEST_EXPECT(buf.size() == 0); ASL_TEST_EXPECT(buf.size() == 0);
ASL_TEST_EXPECT(buf2.size() == 2); ASL_TEST_EXPECT(buf2.size() == 2);
@ -466,7 +466,7 @@ ASL_TEST(move_assign_from_inline_incompatible_allocator)
buf2.push(&d[4]); buf2.push(&d[4]);
buf2.push(&d[5]); buf2.push(&d[5]);
buf2 = ASL_MOVE(buf); buf2 = std::move(buf);
ASL_TEST_EXPECT(buf.size() == 0); ASL_TEST_EXPECT(buf.size() == 0);
ASL_TEST_EXPECT(buf2.size() == 2); ASL_TEST_EXPECT(buf2.size() == 2);

View File

@ -77,7 +77,7 @@ public:
constexpr hash_map() requires default_constructible<Allocator> = default; constexpr hash_map() requires default_constructible<Allocator> = default;
explicit constexpr hash_map(Allocator allocator) explicit constexpr hash_map(Allocator allocator)
: Base{ASL_MOVE(allocator)} : Base{std::move(allocator)}
{} {}
hash_map(const hash_map&) requires copyable<K> && copyable<V> = default; hash_map(const hash_map&) requires copyable<K> && copyable<V> = default;
@ -122,7 +122,7 @@ public:
{ {
ASL_ASSERT((Base::m_tags[result.first_available_index] & Base::kHasValue) == 0); ASL_ASSERT((Base::m_tags[result.first_available_index] & Base::kHasValue) == 0);
Base::m_values[result.first_available_index].construct_unsafe(ASL_MOVE(Base::m_values[result.already_present_index].as_init_unsafe())); Base::m_values[result.first_available_index].construct_unsafe(std::move(Base::m_values[result.already_present_index].as_init_unsafe()));
Base::m_values[result.already_present_index].destroy_unsafe(); Base::m_values[result.already_present_index].destroy_unsafe();
Base::m_tags[result.first_available_index] = result.tag; Base::m_tags[result.first_available_index] = result.tag;
@ -133,17 +133,17 @@ public:
if constexpr (sizeof...(Args1) == 0 && assignable_from<V&, Arg0&&>) if constexpr (sizeof...(Args1) == 0 && assignable_from<V&, Arg0&&>)
{ {
Base::m_values[result.first_available_index].as_init_unsafe().value = ASL_FWD(arg0); Base::m_values[result.first_available_index].as_init_unsafe().value = std::forward<Arg0>(arg0);
} }
else else
{ {
Base::m_values[result.first_available_index].as_init_unsafe().value = ASL_MOVE(V{ASL_FWD(arg0), ASL_FWD(args1)...}); Base::m_values[result.first_available_index].as_init_unsafe().value = std::move(V{std::forward<Arg0>(arg0), std::forward<Args1>(args1)...});
} }
} }
else else
{ {
ASL_ASSERT((Base::m_tags[result.first_available_index] & Base::kHasValue) == 0); ASL_ASSERT((Base::m_tags[result.first_available_index] & Base::kHasValue) == 0);
Base::m_values[result.first_available_index].construct_unsafe(ASL_FWD(key), V{ASL_FWD(arg0), ASL_FWD(args1)...}); Base::m_values[result.first_available_index].construct_unsafe(std::forward<U>(key), V{std::forward<Arg0>(arg0), std::forward<Args1>(args1)...});
Base::m_tags[result.first_available_index] = result.tag; Base::m_tags[result.first_available_index] = result.tag;
Base::m_size += 1; Base::m_size += 1;
} }

View File

@ -115,7 +115,7 @@ protected:
*size += 1; *size += 1;
} }
values[result.first_available_index].construct_unsafe(ASL_MOVE(value)); values[result.first_available_index].construct_unsafe(std::move(value));
tags[result.first_available_index] = result.tag; tags[result.first_available_index] = result.tag;
} }
@ -144,7 +144,7 @@ protected:
{ {
if ((m_tags[i] & kHasValue) == 0) { continue; } if ((m_tags[i] & kHasValue) == 0) { continue; }
insert_inner(ASL_MOVE(m_values[i].as_init_unsafe()), new_tags, new_values, new_capacity, &new_size); insert_inner(std::move(m_values[i].as_init_unsafe()), new_tags, new_values, new_capacity, &new_size);
// Destroy now so that destroy() has less things to do // Destroy now so that destroy() has less things to do
m_values[i].destroy_unsafe(); m_values[i].destroy_unsafe();
@ -312,7 +312,7 @@ public:
{} {}
explicit constexpr hash_set(Allocator allocator) explicit constexpr hash_set(Allocator allocator)
: m_allocator{ASL_MOVE(allocator)} : m_allocator{std::move(allocator)}
{} {}
hash_set(const hash_set& other) hash_set(const hash_set& other)
@ -339,7 +339,7 @@ public:
, m_values{exchange(other.m_values, nullptr)} , m_values{exchange(other.m_values, nullptr)}
, m_capacity{exchange(other.m_capacity, 0)} , m_capacity{exchange(other.m_capacity, 0)}
, m_size{exchange(other.m_size, 0)} , m_size{exchange(other.m_size, 0)}
, m_allocator{ASL_MOVE(other.m_allocator)} , m_allocator{std::move(other.m_allocator)}
{} {}
hash_set& operator=(hash_set&& other) hash_set& operator=(hash_set&& other)
@ -351,7 +351,7 @@ public:
m_values = exchange(other.m_values, nullptr); m_values = exchange(other.m_values, nullptr);
m_capacity = exchange(other.m_capacity, 0); m_capacity = exchange(other.m_capacity, 0);
m_size = exchange(other.m_size, 0); m_size = exchange(other.m_size, 0);
m_allocator = ASL_MOVE(other.m_allocator); m_allocator = std::move(other.m_allocator);
} }
return *this; return *this;
} }
@ -393,7 +393,7 @@ public:
{ {
maybe_grow_to_fit_one_more(); maybe_grow_to_fit_one_more();
ASL_ASSERT(m_size < max_size()); ASL_ASSERT(m_size < max_size());
insert_inner(ASL_MOVE(T{ASL_FWD(args)...}), m_tags, m_values, m_capacity, &m_size); insert_inner(T{std::forward<Args>(args)...}, m_tags, m_values, m_capacity, &m_size);
} }
template<typename U> template<typename U>

View File

@ -170,7 +170,7 @@ ASL_TEST(move)
set1.insert(i); set1.insert(i);
} }
asl::hash_set<int> set2 = ASL_MOVE(set1); asl::hash_set<int> set2 = std::move(set1);
ASL_TEST_EXPECT(set2.size() == 100); ASL_TEST_EXPECT(set2.size() == 100);
for (int i = 0; i < 100; ++i) for (int i = 0; i < 100; ++i)
@ -178,7 +178,7 @@ ASL_TEST(move)
ASL_TEST_EXPECT(set2.contains(i)); ASL_TEST_EXPECT(set2.contains(i));
} }
set1 = ASL_MOVE(set2); set1 = std::move(set2);
ASL_TEST_EXPECT(set1.size() == 100); ASL_TEST_EXPECT(set1.size() == 100);
for (int i = 0; i < 100; ++i) for (int i = 0; i < 100; ++i)

View File

@ -43,8 +43,8 @@ public:
push_front(head); push_front(head);
} }
ASL_DELETE_COPY(IntrusiveList) ASL_DELETE_COPY(IntrusiveList);
ASL_DEFAULT_MOVE(IntrusiveList) ASL_DEFAULT_MOVE(IntrusiveList);
~IntrusiveList() = default; ~IntrusiveList() = default;
constexpr bool is_empty() const { return m_head == nullptr; } constexpr bool is_empty() const { return m_head == nullptr; }

View File

@ -89,7 +89,7 @@ struct HashState
{ {
for (const auto& value: s) for (const auto& value: s)
{ {
h = AslHashValue(ASL_MOVE(h), value); h = AslHashValue(std::move(h), value);
} }
return h; return h;
} }
@ -103,7 +103,7 @@ struct HashState
template<hashable_generic<HashState> Arg, hashable_generic<HashState>... Remaining> template<hashable_generic<HashState> Arg, hashable_generic<HashState>... Remaining>
static constexpr HashState combine(HashState h, const Arg& arg, const Remaining&... remaining) static constexpr HashState combine(HashState h, const Arg& arg, const Remaining&... remaining)
{ {
return combine(AslHashValue(ASL_MOVE(h), arg), remaining...); return combine(AslHashValue(std::move(h), arg), remaining...);
} }
}; };
@ -113,13 +113,13 @@ concept hashable = hashable_generic<T, HashState>;
template<typename H, uniquely_represented T> template<typename H, uniquely_represented T>
constexpr H AslHashValue(H h, const T& value) constexpr H AslHashValue(H h, const T& value)
{ {
return H::combine_contiguous(ASL_MOVE(h), span<const T>{&value, 1}); return H::combine_contiguous(std::move(h), span<const T>{&value, 1});
} }
template<typename H> template<typename H>
constexpr H AslHashValue(H h, bool value) constexpr H AslHashValue(H h, bool value)
{ {
return AslHashValue(ASL_MOVE(h), value ? 1 : 0); return AslHashValue(std::move(h), value ? 1 : 0);
} }
template<typename H, typename T> template<typename H, typename T>
@ -128,7 +128,7 @@ constexpr void AslHashValue(H h, T*); // Don't hash pointers
template<typename H, hashable T> template<typename H, hashable T>
constexpr H AslHashValue(H h, const span<T>& s) constexpr H AslHashValue(H h, const span<T>& s)
{ {
return H::combine_contiguous(ASL_MOVE(h), span<const T>{s.data(), s.size()}); return H::combine_contiguous(std::move(h), span<const T>{s.data(), s.size()});
} }
template<hashable T> template<hashable T>

View File

@ -3,14 +3,22 @@
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
#include "asl/logging/logging.hpp" #include "asl/logging/logging.hpp"
#include "asl/containers/intrusive_list.hpp"
#include "asl/formatting/format.hpp"
#include "asl/io/print.hpp" #include "asl/io/print.hpp"
#include "asl/io/writer.hpp"
#include "asl/strings/string_builder.hpp" #include "asl/strings/string_builder.hpp"
#include "asl/strings/string_view.hpp"
#include "asl/types/span.hpp"
// @Todo Don't use internal get_stdout_writer, make console module // @Todo Don't use internal get_stdout_writer, make console module
// NOLINTNEXTLINE(*-avoid-non-const-global-variables)
static asl::log::DefaultLogger<asl::Writer*> g_default_logger{asl::print_internals::get_stdout_writer()}; static asl::log::DefaultLogger<asl::Writer*> g_default_logger{asl::print_internals::get_stdout_writer()};
// @Todo Protect the loggers list being a mutex // @Todo Protect the loggers list being a mutex
// NOLINTNEXTLINE(*-avoid-non-const-global-variables)
static asl::IntrusiveList<asl::log::Logger> g_loggers(&g_default_logger); static asl::IntrusiveList<asl::log::Logger> g_loggers(&g_default_logger);
void asl::log::register_logger(Logger* logger) void asl::log::register_logger(Logger* logger)
@ -56,7 +64,7 @@ void asl::log::log_inner(
StringWriter msg_writer{}; StringWriter msg_writer{};
asl::format_internals::format(&msg_writer, fmt, args); asl::format_internals::format(&msg_writer, fmt, args);
message m{ const message m{
.level = l, .level = l,
.message = msg_writer.as_string_view(), .message = msg_writer.as_string_view(),
.location = sl, .location = sl,

View File

@ -48,7 +48,11 @@ class DefaultLogger : public DefaultLoggerBase
W m_writer; W m_writer;
public: public:
explicit constexpr DefaultLogger(W&& writer) : m_writer{ASL_FWD(writer)} {} template<typename U>
explicit constexpr DefaultLogger(U&& writer)
requires constructible_from<W, U&&>
: m_writer{std::forward<U>(writer)}
{}
constexpr void log(const message& m) override constexpr void log(const message& m) override
{ {

View File

@ -2,10 +2,11 @@
// //
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
#include "asl/logging/logging.hpp"
#include "asl/testing/testing.hpp"
#include "asl/strings/string_builder.hpp"
#include "asl/base/defer.hpp" #include "asl/base/defer.hpp"
#include "asl/logging/logging.hpp"
#include "asl/strings/string_builder.hpp"
#include "asl/strings/string_view.hpp"
#include "asl/testing/testing.hpp"
ASL_TEST(log) ASL_TEST(log)
{ {
@ -27,6 +28,6 @@ ASL_TEST(custom_writer)
ASL_LOG_INFO("Hello"); ASL_LOG_INFO("Hello");
auto sv = string_writer.as_string_view(); auto sv = string_writer.as_string_view();
ASL_TEST_EXPECT(sv == "[ INFO ] asl/logging/logging_tests.cpp:27: Hello\n"); ASL_TEST_EXPECT(sv == "[ INFO ] asl/logging/logging_tests.cpp:28: Hello\n");
} }

View File

@ -37,7 +37,7 @@ template<typename T>
T* alloc_new(allocator auto& a, auto&&... args) T* alloc_new(allocator auto& a, auto&&... args)
{ {
void* ptr = a.alloc(layout::of<T>()); void* ptr = a.alloc(layout::of<T>());
return construct_at<T>(ptr, ASL_FWD(args)...); return construct_at<T>(ptr, std::forward<decltype(args)>(args)...);
} }
template<typename T> template<typename T>
@ -50,7 +50,7 @@ void alloc_delete(allocator auto& a, T* ptr)
template<typename T> template<typename T>
constexpr T* alloc_new_default(auto&&... args) constexpr T* alloc_new_default(auto&&... args)
{ {
return alloc_new<T>(DefaultAllocator{}, ASL_FWD(args)...); return alloc_new<T>(DefaultAllocator{}, std::forward<decltype(args)>(args)...);
} }
template<typename T> template<typename T>

View File

@ -41,7 +41,7 @@ template<typename T, typename... Args>
constexpr T* construct_at(void* ptr, Args&&... args) constexpr T* construct_at(void* ptr, Args&&... args)
requires constructible_from<T, Args&&...> requires constructible_from<T, Args&&...>
{ {
return new (ptr) T{ ASL_FWD(args)... }; return new (ptr) T{ std::forward<Args>(args)... }; // NOLINT(*-owning-memory)
} }
template<typename T> template<typename T>
@ -112,7 +112,7 @@ constexpr void relocate_uninit_n(T* to, T* from, isize_t n)
for (isize_t i = 0; i < n; ++i) for (isize_t i = 0; i < n; ++i)
{ {
// NOLINTNEXTLINE(*-pointer-arithmetic) // NOLINTNEXTLINE(*-pointer-arithmetic)
construct_at<T>(to + i, ASL_MOVE(from[i])); construct_at<T>(to + i, std::move(from[i]));
} }
destroy_n(from, n); destroy_n(from, n);
} }
@ -131,7 +131,7 @@ constexpr void relocate_assign_n(T* to, T* from, isize_t n)
for (isize_t i = 0; i < n; ++i) for (isize_t i = 0; i < n; ++i)
{ {
// NOLINTNEXTLINE(*-pointer-arithmetic) // NOLINTNEXTLINE(*-pointer-arithmetic)
to[i] = ASL_MOVE(from[i]); to[i] = std::move(from[i]);
} }
destroy_n(from, n); destroy_n(from, n);
} }

View File

@ -16,7 +16,7 @@ class string
buffer<char, Allocator> m_buffer; buffer<char, Allocator> m_buffer;
explicit constexpr string(buffer<char, Allocator>&& buffer) : explicit constexpr string(buffer<char, Allocator>&& buffer) :
m_buffer{ASL_MOVE(buffer)} m_buffer{std::move(buffer)}
{} {}
template<allocator A> template<allocator A>
@ -24,7 +24,7 @@ class string
public: public:
constexpr string() requires default_constructible<Allocator> = default; constexpr string() requires default_constructible<Allocator> = default;
explicit constexpr string(Allocator allocator) : m_buffer{ASL_MOVE(allocator)} {} explicit constexpr string(Allocator allocator) : m_buffer{std::move(allocator)} {}
// NOLINTNEXTLINE(*-explicit-conversions) // NOLINTNEXTLINE(*-explicit-conversions)
constexpr string(string_view sv) constexpr string(string_view sv)
@ -33,7 +33,7 @@ public:
{} {}
constexpr string(string_view sv, Allocator allocator) constexpr string(string_view sv, Allocator allocator)
: m_buffer{sv.as_span(), ASL_MOVE(allocator)} : m_buffer{sv.as_span(), std::move(allocator)}
{} {}
constexpr ~string() = default; constexpr ~string() = default;

View File

@ -20,7 +20,7 @@ class StringBuilder
public: public:
constexpr StringBuilder() requires default_constructible<Allocator> = default; constexpr StringBuilder() requires default_constructible<Allocator> = default;
explicit constexpr StringBuilder(Allocator allocator) : m_buffer{ASL_MOVE(allocator)} {} explicit constexpr StringBuilder(Allocator allocator) : m_buffer{std::move(allocator)} {}
constexpr ~StringBuilder() = default; constexpr ~StringBuilder() = default;
@ -44,23 +44,23 @@ public:
auto push(this auto&& self, string_view sv) -> decltype(self) auto push(this auto&& self, string_view sv) -> decltype(self)
requires (!is_const<un_ref_t<decltype(self)>>) requires (!is_const<un_ref_t<decltype(self)>>)
{ {
isize_t old_size = self.m_buffer.size(); const isize_t old_size = self.m_buffer.size();
self.m_buffer.resize_zero(old_size + sv.size()); self.m_buffer.resize_zero(old_size + sv.size());
// NOLINTNEXTLINE(*-pointer-arithmetic) // NOLINTNEXTLINE(*-pointer-arithmetic)
asl::memcpy(self.m_buffer.data() + old_size, sv.data(), sv.size()); asl::memcpy(self.m_buffer.data() + old_size, sv.data(), sv.size());
return ASL_FWD(self); return std::forward<decltype(self)>(self);
} }
auto push(this auto&& self, char c) -> decltype(self) auto push(this auto&& self, char c) -> decltype(self)
requires (!is_const<un_ref_t<decltype(self)>>) requires (!is_const<un_ref_t<decltype(self)>>)
{ {
self.m_buffer.push(c); self.m_buffer.push(c);
return ASL_FWD(self); return std::forward<decltype(self)>(self);
} }
string<Allocator> finish() && string<Allocator> finish() &&
{ {
return string<Allocator>{ASL_MOVE(m_buffer)}; return string<Allocator>{std::move(m_buffer)};
} }
template<allocator StringAllocator = Allocator> template<allocator StringAllocator = Allocator>
@ -73,7 +73,7 @@ public:
template<allocator StringAllocator = Allocator> template<allocator StringAllocator = Allocator>
string<StringAllocator> as_string(Allocator allocator) const string<StringAllocator> as_string(Allocator allocator) const
{ {
return string<StringAllocator>{as_string_view(), ASL_MOVE(allocator)}; return string<StringAllocator>{as_string_view(), std::move(allocator)};
} }
}; };
@ -86,7 +86,7 @@ class StringWriter : public asl::Writer
public: public:
constexpr StringWriter() requires default_constructible<Allocator> = default; constexpr StringWriter() requires default_constructible<Allocator> = default;
explicit constexpr StringWriter(Allocator allocator) : m_builder{ASL_MOVE(allocator)} {} explicit constexpr StringWriter(Allocator allocator) : m_builder{std::move(allocator)} {}
constexpr ~StringWriter() override = default; constexpr ~StringWriter() override = default;
@ -108,7 +108,7 @@ public:
string<Allocator> finish() && string<Allocator> finish() &&
{ {
return ASL_MOVE(m_builder).finish(); return std::move(m_builder).finish();
} }
template<allocator StringAllocator = Allocator> template<allocator StringAllocator = Allocator>
@ -121,7 +121,7 @@ public:
template<allocator StringAllocator = Allocator> template<allocator StringAllocator = Allocator>
string<StringAllocator> as_string(Allocator allocator) const string<StringAllocator> as_string(Allocator allocator) const
{ {
return m_builder.as_string(ASL_MOVE(allocator)); return m_builder.as_string(std::move(allocator));
} }
}; };
@ -133,15 +133,15 @@ string<Allocator> format_to_string(string_view fmt, const formattable auto&... a
{ {
StringWriter writer{}; StringWriter writer{};
format(&writer, fmt, args...); format(&writer, fmt, args...);
return ASL_MOVE(writer).finish(); return std::move(writer).finish();
} }
template<allocator Allocator = DefaultAllocator> template<allocator Allocator = DefaultAllocator>
string<Allocator> format_to_string(Allocator allocator, string_view fmt, const formattable auto&... args) string<Allocator> format_to_string(Allocator allocator, string_view fmt, const formattable auto&... args)
{ {
StringWriter writer{ASL_MOVE(allocator)}; StringWriter writer{std::move(allocator)};
format(&writer, fmt, args...); format(&writer, fmt, args...);
return ASL_MOVE(writer).finish(); return std::move(writer).finish();
} }
} // namespace asl } // namespace asl

View File

@ -4,37 +4,51 @@
#include "asl/testing/testing.hpp" #include "asl/testing/testing.hpp"
#include "asl/base/assert.hpp"
#include "asl/base/meta.hpp"
#include "asl/base/utility.hpp"
#include "asl/io/print.hpp" #include "asl/io/print.hpp"
static asl::testing::Test* g_head = nullptr; namespace
static asl::testing::Test* g_tail = nullptr; {
struct TestingState
{
asl::testing::Test* head = nullptr;
asl::testing::Test* tail = nullptr;
bool current_test_fail = false;
};
} // namespace
// NOLINTNEXTLINE(*-avoid-non-const-global-variables)
static TestingState g_state{};
void asl::testing::register_test(Test* test) void asl::testing::register_test(Test* test)
{ {
if (g_head == nullptr && g_tail == nullptr) if (g_state.head == nullptr && g_state.tail == nullptr)
{ {
g_head = test; g_state.head = test;
g_tail = test; g_state.tail = test;
} }
else else
{ {
g_tail->m_next = test; g_state.tail->m_next = test;
test->m_prev = asl::exchange(g_tail, test); test->m_prev = asl::exchange(g_state.tail, test);
} }
} }
static bool g_current_test_fail = false;
void asl::testing::report_failure(const char* msg, const asl::source_location& sl) void asl::testing::report_failure(const char* msg, const asl::source_location& sl)
{ {
asl::eprint("--------------------------------------------------------------\n"); asl::eprint("--------------------------------------------------------------\n");
asl::eprint("Test assertion failed at {}, line {}:\n", sl.file, sl.line); asl::eprint("Test assertion failed at {}, line {}:\n", sl.file, sl.line);
asl::eprint(" {}\n", msg); asl::eprint(" {}\n", msg);
asl::eprint("--------------------------------------------------------------\n"); asl::eprint("--------------------------------------------------------------\n");
g_current_test_fail = true; g_state.current_test_fail = true;
} }
static void report_assert_failure(const char* msg, const asl::source_location& sl, void*) static void report_assert_failure(const char* msg, const asl::source_location& sl, void* /* userdata */)
{ {
asl::eprint("------------------------------------------------------------\n"); asl::eprint("------------------------------------------------------------\n");
asl::eprint("Assertion failure at {}, line {}:\n", sl.file, sl.line); asl::eprint("Assertion failure at {}, line {}:\n", sl.file, sl.line);
@ -55,14 +69,14 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
asl::testing::Test* failed_head = nullptr; asl::testing::Test* failed_head = nullptr;
for (auto* it = g_head; it != nullptr; it = it->m_next) for (auto* it = g_state.head; it != nullptr; it = it->m_next)
{ {
asl::eprint(GREEN("[ RUN ]") " {}\n", it->m_case_name); asl::eprint(GREEN("[ RUN ]") " {}\n", it->m_case_name);
g_current_test_fail = false; g_state.current_test_fail = false;
it->m_fn(); it->m_fn();
if (!g_current_test_fail) if (!g_state.current_test_fail)
{ {
asl::eprint(GREEN("[ OK ]") " {}\n", it->m_case_name); asl::eprint(GREEN("[ OK ]") " {}\n", it->m_case_name);
pass += 1; pass += 1;

View File

@ -4,7 +4,7 @@
#pragma once #pragma once
#include "asl/base/utility.hpp" #include "asl/base/meta.hpp"
namespace asl::testing namespace asl::testing
{ {
@ -35,7 +35,8 @@ struct Test
} // namespace asl::testing } // namespace asl::testing
#define ASL_TEST(CASE) \ #define ASL_TEST(CASE) \
static void asl_test_fn_##CASE(); \ static void asl_test_fn_##CASE(); /* NOLINT */ \
/* NOLINTNEXTLINE */ \
static ::asl::testing::Test asl_test_##CASE( \ static ::asl::testing::Test asl_test_##CASE( \
#CASE, \ #CASE, \
asl_test_fn_##CASE); \ asl_test_fn_##CASE); \

View File

@ -29,21 +29,21 @@ public:
constexpr box(T* ptr, Allocator alloc) constexpr box(T* ptr, Allocator alloc)
: m_ptr{ptr} : m_ptr{ptr}
, m_alloc{ASL_MOVE(alloc)} , m_alloc{std::move(alloc)}
{ {
ASL_ASSERT(m_ptr != nullptr); ASL_ASSERT(m_ptr != nullptr);
} }
constexpr box(box&& other) constexpr box(box&& other)
: m_ptr{exchange(other.m_ptr, nullptr)} : 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> template<is_object U>
requires convertible_from<T*, 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_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) constexpr box& operator=(box&& other)
@ -53,7 +53,7 @@ public:
if (m_ptr != nullptr) { reset(); } if (m_ptr != nullptr) { reset(); }
m_ptr = exchange(other.m_ptr, nullptr); m_ptr = exchange(other.m_ptr, nullptr);
m_alloc = ASL_MOVE(other.m_alloc); m_alloc = std::move(other.m_alloc);
return *this; return *this;
} }
@ -99,7 +99,7 @@ public:
requires hashable<T> requires hashable<T>
friend H AslHashValue(H h, const box& b) 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> 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&&...> requires constructible_from<T, Args&&...>
{ {
void* raw_ptr = allocator.alloc(layout::of<T>()); void* raw_ptr = allocator.alloc(layout::of<T>());
auto* ptr = construct_at<T>(raw_ptr, ASL_FWD(args)...); auto* ptr = construct_at<T>(raw_ptr, std::forward<Args>(args)...);
return box(ptr, ASL_MOVE(allocator)); return box(ptr, std::move(allocator));
} }
template<is_object T, allocator Allocator = DefaultAllocator, typename... Args> template<is_object T, allocator Allocator = DefaultAllocator, typename... Args>
@ -124,14 +124,14 @@ constexpr box<T, Allocator> make_box(Args&&... args)
{ {
Allocator allocator{}; Allocator allocator{};
void* raw_ptr = allocator.alloc(layout::of<T>()); void* raw_ptr = allocator.alloc(layout::of<T>());
auto* ptr = construct_at<T>(raw_ptr, ASL_FWD(args)...); auto* ptr = construct_at<T>(raw_ptr, std::forward<Args>(args)...);
return box<T>(ptr, ASL_MOVE(allocator)); return box<T>(ptr, std::move(allocator));
} }
template<is_object T, allocator A> template<is_object T, allocator A>
constexpr T* leak(box<T, A>&& b) constexpr T* leak(box<T, A>&& b)
{ {
return exchange(b.m_ptr, nullptr); return exchange(std::move(b).m_ptr, nullptr);
} }
} // namespace asl } // namespace asl

View File

@ -23,7 +23,7 @@ ASL_TEST(destructor)
ASL_TEST_ASSERT(!d); ASL_TEST_ASSERT(!d);
auto box3 = ASL_MOVE(box); auto box3 = std::move(box);
ASL_TEST_ASSERT(!d); ASL_TEST_ASSERT(!d);
} }
@ -35,7 +35,7 @@ ASL_TEST(value)
auto b = asl::make_box<int>(24); auto b = asl::make_box<int>(24);
ASL_TEST_EXPECT(*b == 24); ASL_TEST_EXPECT(*b == 24);
auto b2 = ASL_MOVE(b); auto b2 = std::move(b);
ASL_TEST_EXPECT(*b2 == 24); ASL_TEST_EXPECT(*b2 == 24);
} }
@ -44,7 +44,7 @@ ASL_TEST(ptr)
auto b = asl::make_box<int>(24); auto b = asl::make_box<int>(24);
auto* ptr1 = b.get(); auto* ptr1 = b.get();
auto b2 = ASL_MOVE(b); auto b2 = std::move(b);
auto* ptr2 = b2.get(); auto* ptr2 = b2.get();
ASL_TEST_EXPECT(ptr1 == ptr2); ASL_TEST_EXPECT(ptr1 == ptr2);
} }

View File

@ -23,7 +23,7 @@ public:
explicit constexpr maybe_uninit(in_place_t, auto&&... args) explicit constexpr maybe_uninit(in_place_t, auto&&... args)
requires constructible_from<T, decltype(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; 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(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> = 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> = 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> = default;
constexpr ~maybe_uninit() requires (!trivially_destructible<T>) {} // NOLINT constexpr ~maybe_uninit() requires (!trivially_destructible<T>) {} // NOLINT
@ -45,14 +45,14 @@ public:
constexpr void construct_unsafe(auto&&... args) constexpr void construct_unsafe(auto&&... args)
requires constructible_from<T, decltype(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 // @Safety Value must have been initialized
constexpr void assign_unsafe(auto&& value) constexpr void assign_unsafe(auto&& value)
requires assignable_from<T&, decltype(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 // @Safety Value must have been initialized
@ -67,7 +67,7 @@ public:
// @Safety Value must have been initialized // @Safety Value must have been initialized
constexpr auto&& as_init_unsafe(this auto&& self) constexpr auto&& as_init_unsafe(this auto&& self)
{ {
return ASL_FWD(self).m_value; return std::forward<decltype(self)>(self).m_value;
} }
}; };

View File

@ -74,19 +74,19 @@ class option
if constexpr (!kHasNiche) if constexpr (!kHasNiche)
{ {
m_payload.construct_unsafe(ASL_FWD(args)...); m_payload.construct_unsafe(std::forward<Args>(args)...);
m_has_value = true; m_has_value = true;
} }
else else
{ {
if constexpr (move_assignable<T>) 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 else
{ {
m_payload.destroy_unsafe(); 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) constexpr void assign(U&& arg)
{ {
ASL_ASSERT(has_value()); ASL_ASSERT(has_value());
m_payload.assign_unsafe(ASL_FWD(arg)); m_payload.assign_unsafe(std::forward<U>(arg));
} }
public: public:
@ -103,10 +103,10 @@ public:
constexpr option() : option{nullopt} {} constexpr option() : option{nullopt} {}
// NOLINTNEXTLINE(*-explicit-conversions) // NOLINTNEXTLINE(*explicit*)
constexpr option(nullopt_t) requires (!kHasNiche) {} constexpr option(nullopt_t) requires (!kHasNiche) {}
// NOLINTNEXTLINE(*-explicit-conversions) // NOLINTNEXTLINE(*explicit*)
constexpr option(nullopt_t) requires kHasNiche : m_payload{in_place, niche_t{}} {} constexpr option(nullopt_t) requires kHasNiche : m_payload{in_place, niche_t{}} {}
template<typename U = T> template<typename U = T>
@ -117,7 +117,7 @@ public:
constructible_from<T, U&&> && constructible_from<T, U&&> &&
!same_as<un_cvref_t<U>, option> !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> template<typename U = T>
@ -128,7 +128,7 @@ public:
constructible_from<T, U&&> && constructible_from<T, U&&> &&
!is_option<U> !is_option<U>
) )
: m_payload{in_place, ASL_FWD(value)} : m_payload{in_place, std::forward<U>(value)}
, m_has_value{true} , m_has_value{true}
{} {}
@ -154,7 +154,7 @@ public:
{ {
if (other.has_value()) 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()) 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()) if (has_value())
{ {
assign(ASL_FWD(value)); assign(std::forward<U>(value));
} }
else else
{ {
construct(ASL_FWD(value)); construct(std::forward<U>(value));
} }
return *this; return *this;
@ -259,11 +259,11 @@ public:
{ {
if (has_value()) if (has_value())
{ {
assign(ASL_MOVE(other.m_payload.as_init_unsafe())); assign(std::move(other.m_payload.as_init_unsafe()));
} }
else else
{ {
construct(ASL_MOVE(other.m_payload.as_init_unsafe())); construct(std::move(other.m_payload.as_init_unsafe()));
} }
} }
else if (has_value()) else if (has_value())
@ -313,11 +313,11 @@ public:
{ {
if (has_value()) if (has_value())
{ {
assign(ASL_MOVE(other.m_payload.as_init_unsafe())); assign(std::move(other).m_payload.as_init_unsafe());
} }
else else
{ {
construct(ASL_MOVE(other.m_payload.as_init_unsafe())); construct(std::move(other).m_payload.as_init_unsafe());
} }
} }
else if (has_value()) else if (has_value())
@ -342,7 +342,7 @@ public:
{ {
if constexpr (move_assignable<T>) if constexpr (move_assignable<T>)
{ {
m_payload.assign_unsafe(ASL_MOVE(T{niche_t{}})); m_payload.assign_unsafe(std::move(T{niche_t{}}));
} }
else else
{ {
@ -357,7 +357,7 @@ public:
} }
} }
constexpr bool has_value() const [[nodiscard]] constexpr bool has_value() const
{ {
if constexpr (kHasNiche) if constexpr (kHasNiche)
{ {
@ -372,28 +372,28 @@ public:
constexpr auto&& value(this auto&& self) constexpr auto&& value(this auto&& self)
{ {
ASL_ASSERT_RELEASE(self.has_value()); 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> template<typename U>
constexpr T value_or(U&& other_value) const& constexpr T value_or(U&& other_value) const&
requires copy_constructible<T> && convertible_from<T, U&&> 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> template<typename U>
constexpr T value_or(U&& other_value) && constexpr T value_or(U&& other_value) &&
requires move_constructible<T> && convertible_from<T, U&&> 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) & constexpr T& emplace(auto&&... args) &
requires constructible_from<T, decltype(args)...> requires constructible_from<T, decltype(args)...>
{ {
if (has_value()) { reset(); } if (has_value()) { reset(); }
construct(ASL_FWD(args)...); construct(std::forward<decltype(args)>(args)...);
return value(); return value();
} }
@ -405,7 +405,7 @@ public:
if (self.has_value()) 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 }; return Result{ asl::nullopt };
} }
@ -417,7 +417,7 @@ public:
if (self.has_value()) if (self.has_value())
{ {
return option<un_cvref_t<Result>>{ 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 }; return option<un_cvref_t<Result>>{ asl::nullopt };
@ -427,14 +427,14 @@ public:
constexpr option or_else(F&& f) const& constexpr option or_else(F&& f) const&
requires same_as<un_cvref_t<invoke_result_t<F>>, option> 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> template<typename F>
constexpr option or_else(F&& f) && constexpr option or_else(F&& f) &&
requires same_as<un_cvref_t<invoke_result_t<F>>, option> 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> template<typename H>
@ -443,9 +443,9 @@ public:
{ {
if (!opt.has_value()) 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());
} }
}; };

View File

@ -129,10 +129,10 @@ ASL_TEST(call_destructor)
{ {
DestructorObserver obs(&destroyed); DestructorObserver obs(&destroyed);
asl::option<DestructorObserver> opt(ASL_MOVE(obs)); asl::option<DestructorObserver> opt(std::move(obs));
ASL_TEST_EXPECT(!destroyed); ASL_TEST_EXPECT(!destroyed);
asl::option<DestructorObserver> opt2 = ASL_MOVE(opt); asl::option<DestructorObserver> opt2 = std::move(opt);
ASL_TEST_EXPECT(!destroyed); ASL_TEST_EXPECT(!destroyed);
} }
@ -172,7 +172,7 @@ ASL_TEST(value_move)
ASL_TEST_EXPECT(!destroyed); ASL_TEST_EXPECT(!destroyed);
{ {
auto x = ASL_MOVE(opt).value(); auto x = std::move(opt).value();
ASL_TEST_EXPECT(!destroyed); ASL_TEST_EXPECT(!destroyed);
} }
@ -208,19 +208,19 @@ ASL_TEST(convert_copy)
ASL_TEST(convert_move) ASL_TEST(convert_move)
{ {
asl::option<uint8_t> opt8 = uint8_t{8}; 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_ASSERT(opt16.has_value());
ASL_TEST_EXPECT(opt16.value() == 8); 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_ASSERT(opt8.has_value());
ASL_TEST_EXPECT(opt8.value() == 10); ASL_TEST_EXPECT(opt8.value() == 10);
opt16 = asl::nullopt; opt16 = asl::nullopt;
ASL_TEST_EXPECT(!opt16.has_value()); ASL_TEST_EXPECT(!opt16.has_value());
opt16 = ASL_MOVE(opt8); opt16 = std::move(opt8);
ASL_TEST_ASSERT(opt16.has_value()); ASL_TEST_ASSERT(opt16.has_value());
ASL_TEST_EXPECT(opt16.value() == 10); ASL_TEST_EXPECT(opt16.value() == 10);
} }

View File

@ -23,7 +23,7 @@ struct StatusInternal
asl::atomic<int32_t> ref_count; asl::atomic<int32_t> ref_count;
constexpr StatusInternal(asl::string<Allocator>&& msg_, asl::status_code code_) constexpr StatusInternal(asl::string<Allocator>&& msg_, asl::status_code code_)
: msg{ASL_MOVE(msg_)} : msg{std::move(msg_)}
, code{code_} , code{code_}
{ {
ASL_ASSERT(code != asl::status_code::ok); 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}; StringWriter<Allocator> sink{g_allocator};
format_internals::format(&sink, fmt, args); 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 asl::status_code asl::status::code_internal() const

View File

@ -122,7 +122,7 @@ public:
return {}; return {};
} }
constexpr status&& throw_status() && { return ASL_MOVE(*this); } constexpr status&& throw_status() && { return std::move(*this); }
friend void AslFormat(Formatter& f, const status&); friend void AslFormat(Formatter& f, const status&);
@ -131,9 +131,9 @@ public:
{ {
if (s.is_inline()) 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_(runtime)
ASL_DEFINE_ERROR_(invalid_argument) 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 } // namespace asl

View File

@ -33,11 +33,11 @@ public:
constexpr status_or(status_or&& other) constexpr status_or(status_or&& other)
requires move_constructible<T> requires move_constructible<T>
: m_status{ASL_MOVE(other.m_status)} : m_status{std::move(other.m_status)}
{ {
if (other.ok()) 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()) 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 else
{ {
@ -84,9 +84,9 @@ public:
} }
else if (other.ok()) 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; return *this;
} }
@ -106,7 +106,7 @@ public:
} }
// NOLINTNEXTLINE(*-explicit-conversions) // 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()); ASL_ASSERT_RELEASE(!m_status.ok());
} }
@ -122,7 +122,7 @@ public:
!same_as<un_cvref_t<U>, status> !same_as<un_cvref_t<U>, status>
) )
: m_status{status_code::ok} : 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(); } constexpr bool ok() const { return m_status.ok(); }
@ -131,26 +131,26 @@ public:
constexpr string_view message() const { return m_status.message(); } 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) constexpr auto&& value(this auto&& self)
{ {
ASL_ASSERT_RELEASE(self.ok()); 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> template<typename U>
constexpr T value_or(U&& other_value) const& constexpr T value_or(U&& other_value) const&
requires copy_constructible<T> && convertible_from<T, U&&> 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> template<typename U>
constexpr T value_or(U&& other_value) && constexpr T value_or(U&& other_value) &&
requires move_constructible<T> && convertible_from<T, U&&> 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) friend void AslFormat(Formatter& f, const status_or& status)
@ -164,9 +164,9 @@ public:
{ {
if (s.ok()) 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);
} }
}; };

View File

@ -52,11 +52,11 @@ ASL_TEST(destructor)
ASL_TEST_EXPECT(s.ok()); ASL_TEST_EXPECT(s.ok());
ASL_TEST_EXPECT(!d); 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(s.ok());
ASL_TEST_EXPECT(!d); ASL_TEST_EXPECT(!d);
s = ASL_MOVE(s2); s = std::move(s2);
ASL_TEST_EXPECT(s.ok()); ASL_TEST_EXPECT(s.ok());
ASL_TEST_EXPECT(!d); ASL_TEST_EXPECT(!d);
} }