*this = p.getFuture();
}
-template <>
-template <class F,
- typename std::enable_if<std::is_void<F>::value, int>::type>
-Future<void>::Future() : core_(nullptr) {
- Promise<void> p;
+template <class T>
+template <class T2,
+ typename std::enable_if<
+ folly::is_void_or_unit<T2>::value,
+ int>::type>
+Future<T>::Future() : core_(nullptr) {
+ Promise<T> p;
p.setValue();
*this = p.getFuture();
}
/* implicit */
template <class T2 = T> Future(T2&& val);
- template <class F = T,
- typename std::enable_if<std::is_void<F>::value, int>::type = 0>
+ template <class T2 = T,
+ typename std::enable_if<
+ folly::is_void_or_unit<T2>::value,
+ int>::type = 0>
Future();
~Future();
--- /dev/null
+/*
+ * Copyright 2015 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <folly/futures/Future.h>
+#include <gtest/gtest.h>
+
+using namespace folly;
+
+TEST(Unit, FutureDefaultCtor) {
+ Future<Unit>();
+}
+
+TEST(Unit, voidOrUnit) {
+ EXPECT_TRUE(is_void_or_unit<void>::value);
+ EXPECT_TRUE(is_void_or_unit<Unit>::value);
+ EXPECT_FALSE(is_void_or_unit<int>::value);
+}