From: Christopher Dykes Date: Thu, 18 Aug 2016 19:50:37 +0000 (-0700) Subject: Fix folly::Expected under MSVC X-Git-Tag: v2016.08.22.00~14 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=96e8ac5bc5d633325e85cbc1d87136ba1ce68120;p=folly.git Fix folly::Expected under MSVC Summary: There are 3 separate issues that this addresses to get Expected working correctly under MSVC. The first is simply that it doesn't like `StrictConjunction`. Switching that to `std::conjunction`, which is part of C++17 and already implemented in MSVC, solves that issue. The second is that MSVC was complaining that all members must be initialized in a `constexpr` constructor, but only one of the base classes of `ExpectedStorage` was being initialized, and, as there were no default `constexpr` constructors for the other bases, they couldn't be initialized. This was solved by making the base class's default constructors `constexpr`. The last was the most fun, as the simple solutions all resulted in internal compiler errors. MSVC doesn't like SFINAE evaluation in the context of a template type parameter on a static operator defined inline in the class via `friend`. The solution is to simply move the definitions after the class and only include the declarations to be able to mark them as `friend`. Reviewed By: ericniebler Differential Revision: D3731833 fbshipit-source-id: ea9244b247b69046866f27cee9fdbd1b2405cafb --- diff --git a/folly/Expected.h b/folly/Expected.h index cde4a04b..0bf217c7 100644 --- a/folly/Expected.h +++ b/folly/Expected.h @@ -92,8 +92,15 @@ using ExpectedErrorType = // Details... namespace expected_detail { +#ifdef _MSC_VER +// MSVC 2015 can't handle the StrictConjunction, so we have +// to use std::conjunction instead. +template