Skip to content

Commit

Permalink
Add [[nodiscard]] to expected<T, E>
Browse files Browse the repository at this point in the history
Summary: We already had a bug around it.

Differential Revision: D68917072

fbshipit-source-id: 49760d62247e14a348cc37ec0c0f32f8cf21e4e8
  • Loading branch information
praihan authored and facebook-github-bot committed Jan 31, 2025
1 parent 2cf5bc3 commit 58ad784
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion third-party/thrift/src/thrift/compiler/whisker/expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace whisker {
* - transform_error
*/
template <typename T, typename E>
class expected;
class [[nodiscard]] expected;

/**
* A type that mimics std::unexpected<E>:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ TEST(ExpectedTest, emplace_never_empty) {
throw std::runtime_error("throw_on_construct");
}
};
EXPECT_THROW((expected<throw_on_construct, int>()), std::runtime_error);
EXPECT_THROW(
(std::ignore = expected<throw_on_construct, int>()), std::runtime_error);
expected<throw_on_construct, int> e = unexpected(1);
EXPECT_EQ(e.error(), 1);

Expand Down

0 comments on commit 58ad784

Please sign in to comment.