Skip to content

Commit 9953c4d

Browse files
Un-doneAndreas Pelczer
authored andcommitted
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 <[email protected]>
1 parent 92cc068 commit 9953c4d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

include/etl/expected.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ namespace etl
188188

189189
//*******************************************
190190
/// Get the error.
191-
//*******************************************
191+
//*******************************************
192192
ETL_CONSTEXPR14 TError&& error() const&& ETL_NOEXCEPT
193193
{
194194
return etl::move(error_value);
@@ -500,7 +500,7 @@ namespace etl
500500
//*******************************************
501501
/// Get the value.
502502
//*******************************************
503-
value_type& value() const
503+
const value_type& value() const
504504
{
505505
return etl::get<Value_Type>(storage);
506506
}
@@ -660,7 +660,7 @@ namespace etl
660660
//*******************************************
661661
///
662662
//*******************************************
663-
error_type& error() const
663+
const error_type& error() const
664664
{
665665
return etl::get<Error_Type>(storage);
666666
}
@@ -932,7 +932,7 @@ namespace etl
932932
/// Returns the error
933933
/// Undefined behaviour if an error has not been set.
934934
//*******************************************
935-
error_type& error() const
935+
const error_type& error() const
936936
{
937937
return etl::get<Error_Type>(storage);
938938
}
@@ -1107,4 +1107,3 @@ void swap(etl::unexpected<TError>& lhs, etl::unexpected<TError>& rhs)
11071107
}
11081108

11091109
#endif
1110-

0 commit comments

Comments
 (0)