From a808626873cde6665fbcb27de4f1a8e16518b2da Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Tue, 25 Feb 2025 00:08:02 +0100 Subject: Start using deducing this, needs more utilities work --- .bazelrc | 4 ++-- asl/base/meta.hpp | 10 +++++----- asl/types/option.hpp | 20 ++++---------------- todo.txt | 1 + 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/.bazelrc b/.bazelrc index 19154d5..1034128 100644 --- a/.bazelrc +++ b/.bazelrc @@ -9,8 +9,8 @@ build:windows --extra_toolchains=@@rules_cc++cc_configure_extension+local_confi build:linux --repo_env=CC=clang -build:windows --cxxopt=-Xclang=-std=c++20 -build:linux --cxxopt=-std=c++20 +build:windows --cxxopt=-Xclang=-std=c++23 +build:linux --cxxopt=-std=c++23 build --cxxopt=-Wall build --cxxopt=-Wno-c++98-compat 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 concept is_integer = _is_integer_helper>::value; template concept is_enum = __is_enum(T); -template struct is_uniquely_represented : false_type {}; -template struct is_uniquely_represented : true_type {}; -template struct is_uniquely_represented : true_type {}; -template<> struct is_uniquely_represented : true_type {}; -template<> struct is_uniquely_represented : true_type {}; +template struct is_uniquely_represented : false_type {}; +template struct is_uniquely_represented : true_type {}; +template struct is_uniquely_represented : true_type {}; +template<> struct is_uniquely_represented : true_type {}; +template<> struct is_uniquely_represented : true_type {}; template concept uniquely_represented = is_uniquely_represented>::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 + 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 diff --git a/todo.txt b/todo.txt index 2c010fa..2922bcd 100644 --- a/todo.txt +++ b/todo.txt @@ -1 +1,2 @@ warning compare with 0 in format_float.cpp +add copy_cvref_t -- cgit