Support compiling in C++14 mode
authorChristopher Dykes <cdykes@fb.com>
Mon, 6 Feb 2017 21:44:18 +0000 (13:44 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 6 Feb 2017 21:49:47 +0000 (13:49 -0800)
Summary:
The rest of Folly isn't dependent on C++17 mode in MSVC, so modify this to support not having it enabled.
This will make adoption easier as C++17 mode acts on the things the standard says are removed.

Reviewed By: yfeldblum

Differential Revision: D4509919

fbshipit-source-id: f4644f5f5ba78de8ab5192b89ac6320767b51084

folly/Traits.h

index ed46cba91ce9778d5741b353a224959c99960fac..877a325f74fd820049daccc71a381ee0f834b1ac 100644 (file)
@@ -302,11 +302,18 @@ struct IsLessThanComparable
     IsLessThanComparable;
 
 namespace traits_detail_IsNothrowSwappable {
-#if defined(_MSC_VER) || defined(__cpp_lib_is_swappable)
-// MSVC already implements the C++17 P0185R1 proposal which
-// adds std::is_nothrow_swappable, so use it instead.
+#if defined(__cpp_lib_is_swappable) || (_CPPLIB_VER && _HAS_CXX17)
+// MSVC 2015+ already implements the C++17 P0185R1 proposal which
+// adds std::is_nothrow_swappable, so use it instead if C++17 mode
+// is enabled.
 template <typename T>
 using IsNothrowSwappable = std::is_nothrow_swappable<T>;
+#elif _CPPLIB_VER
+// MSVC 2015+ defines the base even if C++17 is disabled, and
+// MSVC 2015 has issues with our fallback implementation due to
+// over-eager evaluation of noexcept.
+template <typename T>
+using IsNothrowSwappable = std::_Is_nothrow_swappable<T>;
 #else
 /* using override */ using std::swap;