From af4e29f8c071b089fb46b5d8b964dd2b1fb3f57a Mon Sep 17 00:00:00 2001
From: Steven Le Rouzic <steven.lerouzic@gmail.com>
Date: Tue, 11 Mar 2025 23:51:51 +0100
Subject: Remake deref

---
 asl/types/box.hpp  | 17 ++++++++++-------
 asl/types/span.hpp | 10 +++++-----
 2 files changed, 15 insertions(+), 12 deletions(-)

(limited to 'asl/types')

diff --git a/asl/types/box.hpp b/asl/types/box.hpp
index 6501e3e..bb4e620 100644
--- a/asl/types/box.hpp
+++ b/asl/types/box.hpp
@@ -76,18 +76,21 @@ public:
         }
     }
 
-    constexpr T* get() const { return m_ptr; }
+    constexpr auto* get(this auto&& self)
+    {
+        return self.m_ptr;
+    }
 
-    constexpr T& operator*() const
+    constexpr auto&& operator*(this auto&& self)
     {
-        ASL_ASSERT(m_ptr != nullptr);
-        return *m_ptr;
+        ASL_ASSERT(self.m_ptr != nullptr);
+        return std::forward_like<decltype(self)&&>(*self.m_ptr);
     }
 
-    constexpr T* operator->() const
+    constexpr auto* operator->(this auto&& self)
     {
-        ASL_ASSERT(m_ptr != nullptr);
-        return m_ptr;
+        ASL_ASSERT(self.m_ptr != nullptr);
+        return self.m_ptr;
     }
 
     constexpr bool operator==(niche_t) const
diff --git a/asl/types/span.hpp b/asl/types/span.hpp
index eff6ac7..bb2257a 100644
--- a/asl/types/span.hpp
+++ b/asl/types/span.hpp
@@ -75,21 +75,21 @@ public:
     }
 
     template<isize_t N>
-    constexpr span(T (&array)[N]) // NOLINT(*-explicit-conversions)
+    constexpr span(T (&array)[N]) // NOLINT(*explicit*)
         requires (kIsDynamic)
         : m_data{array}
         , m_size{N}
     {}
 
     template<isize_t N>
-    constexpr span(T (&array)[N]) // NOLINT(*-explicit-conversions)
+    constexpr span(T (&array)[N]) // NOLINT(*explicit*)
         requires (!kIsDynamic) && (N == kSize)
         : m_data{array}
     {}
 
     template<is_object U, isize_t kOtherSize>
     constexpr explicit(!kIsDynamic)
-    span(const span<U, kOtherSize>& other) // NOLINT(*-explicit-conversions)
+    span(const span<U, kOtherSize>& other)
         requires (
             (
                 kIsDynamic ||
@@ -217,7 +217,7 @@ template<is_object T, isize_t kSize>
 inline span<const byte> as_bytes(span<T, kSize> s)
 {
     return span<const byte>(
-        reinterpret_cast<const byte*>(s.data()),
+        reinterpret_cast<const byte*>(s.data()), // NOLINT(*-reinterpret-cast)
         s.size_bytes());
 }
 
@@ -226,7 +226,7 @@ inline span<byte> as_mutable_bytes(span<T, kSize> s)
     requires (!is_const<T>)
 {
     return span<byte>(
-        reinterpret_cast<byte*>(s.data()),
+        reinterpret_cast<byte*>(s.data()), // NOLINT(*-reinterpret-cast)
         s.size_bytes());
 }
 
-- 
cgit