nice error message if you try to Future<void>
authorHans Fugal <fugalh@fb.com>
Thu, 2 Jul 2015 18:43:42 +0000 (11:43 -0700)
committerSara Golemon <sgolemon@fb.com>
Thu, 2 Jul 2015 22:46:00 +0000 (15:46 -0700)
Summary: If you try to make a future or promise of `void`, you will get this nice error message telling you to use `Unit` instead.

Reviewed By: @djwatson

Differential Revision: D2211239

folly/futures/detail/Core.h

index f00188622d5f473c6cbdeb071d2adb4e9f58eeab..a01285fa0420e02dc472331f9f02d1c9f49e15b1 100644 (file)
@@ -74,6 +74,8 @@ enum class State : uint8_t {
 /// time there won't be any problems.
 template<typename T>
 class Core {
+  static_assert(!std::is_void<T>::value,
+                "void futures are not supported. Use Unit instead.");
  public:
   /// This must be heap-constructed. There's probably a way to enforce that in
   /// code but since this is just internal detail code and I don't know how