instance Eq Unit
authorYedidya Feldblum <yfeldblum@fb.com>
Tue, 23 Jun 2015 03:29:35 +0000 (20:29 -0700)
committerSara Golemon <sgolemon@fb.com>
Tue, 23 Jun 2015 18:24:16 +0000 (11:24 -0700)
Summary: [Folly] instance Eq Unit

    Unit::operator==(const Unit&)
    Unit::operator!=(const Unit&)

Reviewed By: @Gownta

Differential Revision: D2179384

folly/futures/Unit.h
folly/futures/test/UnitTest.cpp

index 9d67bf0fc68114e8cf4573bf8b6abd34758d48ed..44c3661b0063eb22e4e574498b926360519f2c7d 100644 (file)
@@ -29,6 +29,8 @@ struct Unit {
   template <class T> 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.
index 965a830e98be6a6e7af4f8f06c4f3e172c7fab9b..7e09a10b6f73056ac5b79685cb0b1bdd934f2f11 100644 (file)
@@ -26,6 +26,14 @@ TEST(Unit, futureDefaultCtor) {
   Future<Unit>();
 }
 
+TEST(Unit, operatorEq) {
+  EXPECT_TRUE(Unit{} == Unit{});
+}
+
+TEST(Unit, operatorNe) {
+  EXPECT_FALSE(Unit{} != Unit{});
+}
+
 TEST(Unit, voidOrUnit) {
   EXPECT_TRUE(is_void_or_unit<void>::value);
   EXPECT_TRUE(is_void_or_unit<Unit>::value);