[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 .

llvm-svn: 280058
This commit is contained in:
Lang Hames 2016-08-30 05:32:41 +00:00
parent 4bcf6b6de2
commit 57bafedfaf
1 changed files with 21 additions and 0 deletions

View File

@ -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)