From c547b7804fb86be2edabd0e55f0b0e3fb8d51149 Mon Sep 17 00:00:00 2001 From: Andreas Date: Wed, 26 Mar 2025 13:17:23 +0100 Subject: [PATCH] Returning const ref of member from const member function (#1052) The `const` marked function needs to return a `const` reference to a member variable Co-authored-by: Andreas Pelczer --- include/etl/expected.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/etl/expected.h b/include/etl/expected.h index 3f1abd99..fd68ac85 100644 --- a/include/etl/expected.h +++ b/include/etl/expected.h @@ -188,7 +188,7 @@ namespace etl //******************************************* /// Get the error. - //******************************************* + //******************************************* ETL_CONSTEXPR14 TError&& error() const&& ETL_NOEXCEPT { return etl::move(error_value); @@ -500,7 +500,7 @@ namespace etl //******************************************* /// Get the value. //******************************************* - value_type& value() const + const value_type& value() const { return etl::get(storage); } @@ -660,7 +660,7 @@ namespace etl //******************************************* /// //******************************************* - error_type& error() const + const error_type& error() const { return etl::get(storage); } @@ -932,7 +932,7 @@ namespace etl /// Returns the error /// Undefined behaviour if an error has not been set. //******************************************* - error_type& error() const + const error_type& error() const { return etl::get(storage); } @@ -1107,4 +1107,3 @@ void swap(etl::unexpected& lhs, etl::unexpected& rhs) } #endif -