diff --git a/develop/singles/headers/meta.hpp/meta_all.hpp b/develop/singles/headers/meta.hpp/meta_all.hpp index 6a7e611..adcc87c 100644 --- a/develop/singles/headers/meta.hpp/meta_all.hpp +++ b/develop/singles/headers/meta.hpp/meta_all.hpp @@ -3115,10 +3115,18 @@ namespace meta_hpp [[nodiscard]] bool has_value() const noexcept; [[nodiscard]] explicit operator bool() const noexcept; - [[nodiscard]] uvalue& get_value() &; - [[nodiscard]] uvalue&& get_value() &&; - [[nodiscard]] const uvalue& get_value() const&; - [[nodiscard]] const uvalue&& get_value() const&&; + [[nodiscard]] uvalue* operator->() noexcept; + [[nodiscard]] const uvalue* operator->() const noexcept; + + [[nodiscard]] uvalue& operator*() & noexcept; + [[nodiscard]] uvalue&& operator*() && noexcept; + [[nodiscard]] const uvalue& operator*() const& noexcept; + [[nodiscard]] const uvalue&& operator*() const&& noexcept; + + [[nodiscard]] uvalue& get_value() & noexcept; + [[nodiscard]] uvalue&& get_value() && noexcept; + [[nodiscard]] const uvalue& get_value() const& noexcept; + [[nodiscard]] const uvalue&& get_value() const&& noexcept; [[nodiscard]] error_code get_error() const noexcept; @@ -9284,19 +9292,44 @@ namespace meta_hpp return has_value(); } - inline uvalue& uresult::get_value() & { + inline uvalue* uresult::operator->() noexcept { + return std::addressof(value_); + } + + inline const uvalue* uresult::operator->() const noexcept { + return std::addressof(value_); + } + + inline uvalue& uresult::operator*() & noexcept { return value_; } - inline uvalue&& uresult::get_value() && { + inline uvalue&& uresult::operator*() && noexcept { return std::move(value_); } - inline const uvalue& uresult::get_value() const& { + inline const uvalue& uresult::operator*() const& noexcept { return value_; } - inline const uvalue&& uresult::get_value() const&& { + inline const uvalue&& uresult::operator*() const&& noexcept { + // NOLINTNEXTLINE(*-move-const-arg) + return std::move(value_); + } + + inline uvalue& uresult::get_value() & noexcept { + return value_; + } + + inline uvalue&& uresult::get_value() && noexcept { + return std::move(value_); + } + + inline const uvalue& uresult::get_value() const& noexcept { + return value_; + } + + inline const uvalue&& uresult::get_value() const&& noexcept { // NOLINTNEXTLINE(*-move-const-arg) return std::move(value_); } diff --git a/develop/untests/meta_utilities/result_tests.cpp b/develop/untests/meta_utilities/result_tests.cpp index c7ee53d..c58e002 100644 --- a/develop/untests/meta_utilities/result_tests.cpp +++ b/develop/untests/meta_utilities/result_tests.cpp @@ -297,10 +297,34 @@ TEST_CASE("meta/meta_utilities/uresult") { static_assert(std::is_same_v().get_value())>); static_assert(std::is_same_v().get_value())>); - meta::uresult res{ivec2{42, 21}}; - CHECK(res.get_value().as() == ivec2{42, 21}); - CHECK(std::move(res).get_value().as() == ivec2{42, 21}); - CHECK(std::as_const(res).get_value().as() == ivec2{42, 21}); - CHECK(std::move(std::as_const(res)).get_value().as() == ivec2{42, 21}); + static_assert(std::is_same_v().operator*())>); + static_assert(std::is_same_v().operator*())>); + static_assert(std::is_same_v().operator*())>); + static_assert(std::is_same_v().operator*())>); + + static_assert(std::is_same_v().operator->())>); + static_assert(std::is_same_v().operator->())>); + + { + meta::uresult res{ivec2{42, 21}}; + CHECK(res.get_value().as() == ivec2{42, 21}); + CHECK(std::move(res).get_value().as() == ivec2{42, 21}); + CHECK(std::as_const(res).get_value().as() == ivec2{42, 21}); + CHECK(std::move(std::as_const(res)).get_value().as() == ivec2{42, 21}); + } + + { + meta::uresult res{ivec2{42, 21}}; + CHECK((*res).as() == ivec2{42, 21}); + CHECK((*std::move(res)).as() == ivec2{42, 21}); + CHECK((*std::as_const(res)).as() == ivec2{42, 21}); + CHECK((*std::move(std::as_const(res))).as() == ivec2{42, 21}); + } + + { + meta::uresult res{ivec2{42, 21}}; + CHECK(res->as() == ivec2{42, 21}); + CHECK(std::as_const(res)->as() == ivec2{42, 21}); + } } } diff --git a/headers/meta.hpp/meta_uresult.hpp b/headers/meta.hpp/meta_uresult.hpp index 8f36640..28d8f5e 100644 --- a/headers/meta.hpp/meta_uresult.hpp +++ b/headers/meta.hpp/meta_uresult.hpp @@ -123,10 +123,18 @@ namespace meta_hpp [[nodiscard]] bool has_value() const noexcept; [[nodiscard]] explicit operator bool() const noexcept; - [[nodiscard]] uvalue& get_value() &; - [[nodiscard]] uvalue&& get_value() &&; - [[nodiscard]] const uvalue& get_value() const&; - [[nodiscard]] const uvalue&& get_value() const&&; + [[nodiscard]] uvalue* operator->() noexcept; + [[nodiscard]] const uvalue* operator->() const noexcept; + + [[nodiscard]] uvalue& operator*() & noexcept; + [[nodiscard]] uvalue&& operator*() && noexcept; + [[nodiscard]] const uvalue& operator*() const& noexcept; + [[nodiscard]] const uvalue&& operator*() const&& noexcept; + + [[nodiscard]] uvalue& get_value() & noexcept; + [[nodiscard]] uvalue&& get_value() && noexcept; + [[nodiscard]] const uvalue& get_value() const& noexcept; + [[nodiscard]] const uvalue&& get_value() const&& noexcept; [[nodiscard]] error_code get_error() const noexcept; diff --git a/headers/meta.hpp/meta_uresult/uresult.hpp b/headers/meta.hpp/meta_uresult/uresult.hpp index 820f6dd..63e7c27 100644 --- a/headers/meta.hpp/meta_uresult/uresult.hpp +++ b/headers/meta.hpp/meta_uresult/uresult.hpp @@ -120,19 +120,44 @@ namespace meta_hpp return has_value(); } - inline uvalue& uresult::get_value() & { + inline uvalue* uresult::operator->() noexcept { + return std::addressof(value_); + } + + inline const uvalue* uresult::operator->() const noexcept { + return std::addressof(value_); + } + + inline uvalue& uresult::operator*() & noexcept { return value_; } - inline uvalue&& uresult::get_value() && { + inline uvalue&& uresult::operator*() && noexcept { return std::move(value_); } - inline const uvalue& uresult::get_value() const& { + inline const uvalue& uresult::operator*() const& noexcept { return value_; } - inline const uvalue&& uresult::get_value() const&& { + inline const uvalue&& uresult::operator*() const&& noexcept { + // NOLINTNEXTLINE(*-move-const-arg) + return std::move(value_); + } + + inline uvalue& uresult::get_value() & noexcept { + return value_; + } + + inline uvalue&& uresult::get_value() && noexcept { + return std::move(value_); + } + + inline const uvalue& uresult::get_value() const& noexcept { + return value_; + } + + inline const uvalue&& uresult::get_value() const&& noexcept { // NOLINTNEXTLINE(*-move-const-arg) return std::move(value_); }