#pragma once
namespace folly {
-struct Unit {};
+struct Unit {
+ template <class T> struct Lift : public std::false_type {
+ using type = T;
+ };
+};
+
+template <>
+struct Unit::Lift<void> : public std::true_type {
+ using type = Unit;
+};
template <class T>
struct is_void_or_unit : public std::conditional<
Promise<Unit> p;
p.setValue();
}
+
+TEST(Unit, LiftInt) {
+ using Lifted = Unit::Lift<int>;
+ EXPECT_FALSE(Lifted::value);
+ auto v = std::is_same<int, Lifted::type>::value;
+ EXPECT_TRUE(v);
+}
+
+TEST(Unit, LiftVoid) {
+ using Lifted = Unit::Lift<void>;
+ EXPECT_TRUE(Lifted::value);
+ auto v = std::is_same<Unit, Lifted::type>::value;
+ EXPECT_TRUE(v);
+}