@@ -76,7 +76,7 @@ template <typename E>
7676// copy assignment operators.
7777// NOLINTBEGIN(cppcoreguidelines-special-member-functions): shall be implicitly declared as per the C++23 standard.
7878// coverity[autosar_cpp14_a12_0_1_violation]
79- class unexpected : impl::base_unexpected
79+ class [[nodiscard]] unexpected : impl::base_unexpected
8080// NOLINTEND(cppcoreguidelines-special-member-functions): shall be implicitly declared as per the C++23 standard.
8181{
8282 public:
@@ -115,24 +115,24 @@ class unexpected : impl::base_unexpected
115115 // NOLINTNEXTLINE(performance-noexcept-move-constructor) qualification from the move assignment operator of E.
116116 constexpr unexpected& operator =(unexpected&&) = default ;
117117
118- constexpr const E& error () const & noexcept
118+ [[nodiscard]] constexpr const E& error () const & noexcept
119119 {
120120 return value_;
121121 }
122- constexpr E& error () & noexcept
122+ [[nodiscard]] constexpr E& error () & noexcept
123123 {
124124 // coverity[autosar_cpp14_a9_3_1_violation] by design
125125 return value_;
126126 }
127- constexpr const E&& error() const && noexcept
127+ [[nodiscard]] constexpr const E&& error () const && noexcept
128128 {
129129 // Suppress AUTOSAR C++14 A18-9-3" rule violations. The rule states "The std::move shall not be used on objects
130130 // declared const or const&." the move operation on a const object does not cause unintended behavior it ensures
131131 // a proper copy/move of underlying values.
132132 // coverity[autosar_cpp14_a18_9_3_violation]
133133 return std::move (value_);
134134 }
135- constexpr E&& error() && noexcept
135+ [[nodiscard]] constexpr E&& error () && noexcept
136136 {
137137 return std::move (value_);
138138 }
@@ -208,7 +208,7 @@ unexpected(E) -> unexpected<E>;
208208#endif
209209
210210template <typename T, typename E>
211- class SPP_EXPECTED_NODISCARD expected : impl::base_expected
211+ class [[nodiscard]] expected : impl::base_expected
212212{
213213 // Suppress "AUTOSAR C++14 A5-1-7" rule finding. This rule states: "A lambda shall not be an operand to decltype or
214214 // typeid". False-positive, at this point "decltype" is not used with lambda.
@@ -1031,7 +1031,7 @@ class SPP_EXPECTED_NODISCARD expected : impl::base_expected
10311031};
10321032
10331033template <typename E>
1034- class SPP_EXPECTED_NODISCARD expected<void , E> : impl::base_expected
1034+ class [[nodiscard]] expected<void , E> : impl::base_expected
10351035{
10361036 // Suppress "AUTOSAR C++14 A5-1-7" rule finding. This rule states: "A lambda shall not be an operand to decltype or
10371037 // typeid". False-positive, at this point "decltype" is not used with lambda.
0 commit comments