diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-02-25 00:08:02 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-02-25 00:08:11 +0100 |
commit | a808626873cde6665fbcb27de4f1a8e16518b2da (patch) | |
tree | 8b81897a8c6070b7b57f86f6a98da2531d0ec84a /asl | |
parent | aa73023bee1aebc745188e54039d3bf567be97e3 (diff) |
Start using deducing this, needs more utilities work
Diffstat (limited to 'asl')
-rw-r--r-- | asl/base/meta.hpp | 10 | ||||
-rw-r--r-- | asl/types/option.hpp | 20 |
2 files changed, 9 insertions, 21 deletions
diff --git a/asl/base/meta.hpp b/asl/base/meta.hpp index ce17420..17a7620 100644 --- a/asl/base/meta.hpp +++ b/asl/base/meta.hpp @@ -193,11 +193,11 @@ template<typename T> concept is_integer = _is_integer_helper<un_cv_t<T>>::value; template<typename T> concept is_enum = __is_enum(T); -template<typename T> struct is_uniquely_represented : false_type {}; -template<is_integer T> struct is_uniquely_represented<T> : true_type {}; -template<is_enum T> struct is_uniquely_represented<T> : true_type {}; -template<> struct is_uniquely_represented<uint128_t> : true_type {}; -template<> struct is_uniquely_represented<byte> : true_type {}; +template<typename T> struct is_uniquely_represented : false_type {}; +template<is_integer T> struct is_uniquely_represented<T> : true_type {}; +template<is_enum T> struct is_uniquely_represented<T> : true_type {}; +template<> struct is_uniquely_represented<uint128_t> : true_type {}; +template<> struct is_uniquely_represented<byte> : true_type {}; template<typename T> concept uniquely_represented = is_uniquely_represented<un_cv_t<T>>::value; diff --git a/asl/types/option.hpp b/asl/types/option.hpp index 86cfca3..5cbb759 100644 --- a/asl/types/option.hpp +++ b/asl/types/option.hpp @@ -365,23 +365,11 @@ public: } } - // @Todo(C++23) Deducing this - constexpr T&& value() && + template<typename Self> + constexpr auto&& value(this Self&& self) { - ASL_ASSERT_RELEASE(has_value()); - return ASL_MOVE(m_payload).as_init_unsafe(); - } - - constexpr T& value() & - { - ASL_ASSERT_RELEASE(has_value()); - return m_payload.as_init_unsafe(); - } - - constexpr const T& value() const& - { - ASL_ASSERT_RELEASE(has_value()); - return m_payload.as_init_unsafe(); + ASL_ASSERT_RELEASE(self.has_value()); + return ASL_FWD(self).m_payload.as_init_unsafe(); } template<typename U> |