auto oup = folly::make_optional(folly::make_unique<int>(5));
// optional has a value, and that value is non-null
- EXPECT_TRUE(oup | unwrap);
+ EXPECT_TRUE(bool(oup | unwrap));
EXPECT_EQ(5, *(oup | unwrap));
EXPECT_TRUE(oup.hasValue()); // still has a pointer (null or not)
- EXPECT_TRUE(oup.value()); // that value isn't null
+ EXPECT_TRUE(bool(oup.value())); // that value isn't null
auto moved1 = std::move(oup) | unwrapOr(folly::make_unique<int>(6));
// oup still has a value, but now it's now nullptr since the pointer was moved
// into moved1
EXPECT_TRUE(oup.hasValue());
EXPECT_FALSE(oup.value());
- EXPECT_TRUE(moved1);
+ EXPECT_TRUE(bool(moved1));
EXPECT_EQ(5, *moved1);
auto moved2 = std::move(oup) | unwrapOr(folly::make_unique<int>(7));
oup.clear();
auto moved3 = std::move(oup) | unwrapOr(folly::make_unique<int>(8));
// oup is empty now, so the unwrapOr comes into play.
- EXPECT_TRUE(moved3);
+ EXPECT_TRUE(bool(moved3));
EXPECT_EQ(8, *moved3);
{
auto fallback = unwrapOr(folly::make_unique<int>(9));
// fallback must be std::move'd to be used
EXPECT_EQ(8, *(opt | std::move(fallback)));
- EXPECT_TRUE(opt.value()); // shared_ptr copied out, not moved
- EXPECT_TRUE(opt); // value still present
- EXPECT_TRUE(fallback.value()); // fallback value not needed
+ EXPECT_TRUE(bool(opt.value())); // shared_ptr copied out, not moved
+ EXPECT_TRUE(bool(opt)); // value still present
+ EXPECT_TRUE(bool(fallback.value())); // fallback value not needed
EXPECT_EQ(8, *(std::move(opt) | std::move(fallback)));
EXPECT_FALSE(opt.value()); // shared_ptr moved out
- EXPECT_TRUE(opt); // gutted value still present
- EXPECT_TRUE(fallback.value()); // fallback value not needed
+ EXPECT_TRUE(bool(opt)); // gutted value still present
+ EXPECT_TRUE(bool(fallback.value())); // fallback value not needed
opt.clear();