[llvm] r280058 - [Support] Add a conditionally defined default constructor (available on MSVC

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 29 22:32:42 PDT 2016


Author: lhames
Date: Tue Aug 30 00:32:41 2016
New Revision: 280058

URL: http://llvm.org/viewvc/llvm-project?rev=280058&view=rev
Log:
[Support] Add a conditionally defined default constructor (available on MSVC
only) for Expected<T> so that it can interoperate with MSVC's std::future
implementation.

MSVC 2013's std::future implementation requires the wrapped type to be default
constructible.

Hopefully this will fix the bot breakage in
http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/9937 .


Modified:
    llvm/trunk/include/llvm/Support/Error.h

Modified: llvm/trunk/include/llvm/Support/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Error.h?rev=280058&r1=280057&r2=280058&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Error.h (original)
+++ llvm/trunk/include/llvm/Support/Error.h Tue Aug 30 00:32:41 2016
@@ -629,6 +629,27 @@ private:
   typedef const typename std::remove_reference<T>::type *const_pointer;
 
 public:
+
+#ifdef _MSC_VER
+  // WARNING: This constructor should *never* be called in user code.
+  // It is provided under MSVC only so that Expected can be used
+  // with MSVC's <future> header, which requires types to be default
+  // constructible.
+  //
+  // FIXME; Kill this as soon as MSVC's <future> implementation no longer
+  // requires types to be default constructible.
+  Expected()
+      : HasError(true)
+#ifndef NDEBUG
+        ,
+        Checked(true)
+#endif // NDEBUG
+  {
+    new (getErrorStorage()) Error();
+    !!*getErrorStorage();
+  }
+#endif // _MSC_VER
+
   /// Create an Expected<T> error value from the given Error.
   Expected(Error Err)
       : HasError(true)




More information about the llvm-commits mailing list