summaryrefslogtreecommitdiff
path: root/asl/types
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2025-03-11 23:51:51 +0100
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2025-03-11 23:51:51 +0100
commitaf4e29f8c071b089fb46b5d8b964dd2b1fb3f57a (patch)
tree13d2607d79b54750bca4d7ef11220faa9e4eecc0 /asl/types
parent636882316b5191931e144212d93665c10859ac95 (diff)
Remake deref
Diffstat (limited to 'asl/types')
-rw-r--r--asl/types/box.hpp17
-rw-r--r--asl/types/span.hpp10
2 files changed, 15 insertions, 12 deletions
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());
}