From ed9f25401f35be98eadc627b6aa35058bed67135 Mon Sep 17 00:00:00 2001 From: Louis-Charles Caron Date: Tue, 7 Nov 2023 07:05:35 +0100 Subject: [PATCH] Revert "Allow chaining -> with pointer-like value types." This reverts commit 2321c7d7c2005a0c4b9309d83202df4f3bc78172. --- include/safe/safe.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/include/safe/safe.h b/include/safe/safe.h index 1e1af84..e4cfa09 100644 --- a/include/safe/safe.h +++ b/include/safe/safe.h @@ -85,6 +85,10 @@ template class Safe typename std::conditional::type; public: + /// Pointer-to-const ValueType + using ConstPointerType = const ConstIfReadOnlyValueType *; + /// Pointer-to-const ValueType if Mode is ReadOnly, pointer to ValueType otherwise. + using PointerType = ConstIfReadOnlyValueType *; /// Reference-to-const ValueType using ConstReferenceType = const ConstIfReadOnlyValueType &; /// Reference-to-const ValueType if Mode is ReadOnly, reference to ValueType otherwise. @@ -161,25 +165,25 @@ template class Safe /** * @brief Const accessor to the value. - * @return ConstReferenceType Const pointer to the protected value. + * @return ConstPointerType Const pointer to the protected value. */ - ConstReferenceType operator->() const noexcept + ConstPointerType operator->() const noexcept { - return m_value; + return &m_value; } /** * @brief Accessor to the value. - * @return ReferenceType Reference to the protected value. + * @return ValuePointerType Pointer to the protected value. */ - ReferenceType operator->() noexcept + PointerType operator->() noexcept { - return m_value; + return &m_value; } /** * @brief Const accessor to the value. - * @return ConstReferenceType Const reference to the protected value. + * @return ConstValueReferenceType Const reference to the protected value. */ ConstReferenceType operator*() const noexcept { @@ -188,7 +192,7 @@ template class Safe /** * @brief Accessor to the value. - * @return ReferenceType Reference to the protected. + * @return ValueReferenceType Reference to the protected. */ ReferenceType operator*() noexcept {