From bcf360a905b6a443d23ab0433ec64d79cc191cb6 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Mon, 22 Jun 2015 20:29:35 -0700 Subject: [PATCH] instance Eq Unit Summary: [Folly] instance Eq Unit Unit::operator==(const Unit&) Unit::operator!=(const Unit&) Reviewed By: @Gownta Differential Revision: D2179384 --- folly/futures/Unit.h | 2 ++ folly/futures/test/UnitTest.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/folly/futures/Unit.h b/folly/futures/Unit.h index 9d67bf0f..44c3661b 100644 --- a/folly/futures/Unit.h +++ b/folly/futures/Unit.h @@ -29,6 +29,8 @@ struct Unit { template struct Lift : public std::false_type { using type = T; }; + bool operator==(const Unit& other) const { return true; } + bool operator!=(const Unit& other) const { return false; } }; // Lift void into Unit. diff --git a/folly/futures/test/UnitTest.cpp b/folly/futures/test/UnitTest.cpp index 965a830e..7e09a10b 100644 --- a/folly/futures/test/UnitTest.cpp +++ b/folly/futures/test/UnitTest.cpp @@ -26,6 +26,14 @@ TEST(Unit, futureDefaultCtor) { Future(); } +TEST(Unit, operatorEq) { + EXPECT_TRUE(Unit{} == Unit{}); +} + +TEST(Unit, operatorNe) { + EXPECT_FALSE(Unit{} != Unit{}); +} + TEST(Unit, voidOrUnit) { EXPECT_TRUE(is_void_or_unit::value); EXPECT_TRUE(is_void_or_unit::value); -- 2.34.1