Commit 3498c54a authored by Zonr Chang's avatar Zonr Chang Committed by Facebook Github Bot 5

Make type conversion from Expected<> to bool explicitly.

Summary: Closes https://github.com/facebook/folly/pull/465

Reviewed By: yfeldblum

Differential Revision: D3787146

Pulled By: Orvid

fbshipit-source-id: 17433a256338bd107eec41e69af3eef58de3339b
parent 6c5a2189
......@@ -64,17 +64,17 @@ TEST(Expected, NoDefault) {
static_assert(
std::is_default_constructible<Expected<NoDefault, int>>::value, "");
Expected<NoDefault, int> x{in_place, 42, 42};
EXPECT_TRUE(x);
EXPECT_TRUE(bool(x));
x.emplace(4, 5);
EXPECT_TRUE(bool(x));
x = makeUnexpected(42);
EXPECT_FALSE(x);
EXPECT_FALSE(bool(x));
EXPECT_EQ(42, x.error());
}
TEST(Expected, String) {
Expected<std::string, int> maybeString;
EXPECT_FALSE(maybeString);
EXPECT_FALSE(bool(maybeString));
EXPECT_EQ(0, maybeString.error());
maybeString = "hello";
EXPECT_TRUE(bool(maybeString));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment