From: Yedidya Feldblum Date: Tue, 23 Jun 2015 03:29:35 +0000 (-0700) Subject: instance Eq Unit X-Git-Tag: v0.48.0~26 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bcf360a905b6a443d23ab0433ec64d79cc191cb6;p=folly.git instance Eq Unit Summary: [Folly] instance Eq Unit Unit::operator==(const Unit&) Unit::operator!=(const Unit&) Reviewed By: @Gownta Differential Revision: D2179384 --- 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);