From a1b57262712392b8d5f30a095a7e569cb12ce3a7 Mon Sep 17 00:00:00 2001 From: CHatingPython Date: Wed, 3 Jun 2026 11:10:01 +0200 Subject: [PATCH] refactor(handle): remove non-pointer handle Previous commit rendered it obsolete. Refs: #1 --- furc/include/furc/handle.hpp | 91 ------------------------------------ 1 file changed, 91 deletions(-) diff --git a/furc/include/furc/handle.hpp b/furc/include/furc/handle.hpp index 85cfb4e..e0b9d2e 100644 --- a/furc/include/furc/handle.hpp +++ b/furc/include/furc/handle.hpp @@ -15,97 +15,6 @@ namespace furc { template class handle; -template -class handle { - template - friend class handle; - - friend std::ostream& operator<<(std::ostream& os, const handle& result); -public: - using value_type = std::remove_reference_t; - using pointer = value_type*; - using const_pointer = const value_type*; - using reference = T&; - using const_reference = const T&; -public: - handle(location location, value_type&& value) - : m_location(location), m_value(std::move(value)) {} - - template >> - handle(location location, Args&&... args) - : m_location(location), m_value(value_type(std::forward(args)...)) {} - - handle(location location, Error&& error) - : m_location(location), m_error(std::move(error)) {} - - template - handle(const handle& error) - : m_location(error.location()), m_error(error.error()) {} - - ~handle() = default; - - handle(handle&& other) noexcept - : m_location(other.m_location), m_value(std::move(other.m_value)), m_error(std::move(other.m_error)) { - other.m_value.reset(); - } - - handle(const handle&) = delete; - - handle& operator=(handle&& other) noexcept { - if (this == &other) return *this; - m_location = other.m_location; - m_value = other.m_value; - m_error = std::move(other.m_error); - other.m_value.reset(); - return *this; - } - - handle& operator=(const handle&) = delete; -public: - location location() const { return m_location; } - - bool present() const { return m_value.has_value(); } - bool has_error() const { return !m_value.has_value(); } - - value_type move() { - value_type value = std::move(*m_value); - m_value.reset(); - return value; - } - - Error error() const { return m_error; } - - reference operator*() { return m_value.value(); } // NOLINT(bugprone-unchecked-optional-access) - const_reference operator*() const { return m_value.value(); } // NOLINT(bugprone-unchecked-optional-access) - pointer operator->() { return &m_value.value(); } // NOLINT(bugprone-unchecked-optional-access) - const_pointer operator->() const { return &m_value.value(); } // NOLINT(bugprone-unchecked-optional-access) -public: - bool operator==(const handle& rhs) const { - if (present() != rhs.present() || error() != rhs.error()) return false; - if (m_value.has_value() && m_value.value() != rhs.m_value.value()) // NOLINT(bugprone-unchecked-optional-access) - return false; - return true; - } - - bool operator==(const T& rhs) const { - return m_value.has_value() && *m_value == rhs; // NOLINT(bugprone-unchecked-optional-access) - } -public: - friend std::ostream& operator<<(std::ostream& os, const handle& result) { - os << result.m_location << ": "; - if (result.m_value.has_value()) { - os << *result.m_value; - } else { - os << "ERROR: " << result.m_error; - } - return os; - } -private: - struct location m_location; - std::optional m_value = {}; - Error m_error; -}; - template class handle { template