Use std::is_nothrow_swappable under MSVC
authorChristopher Dykes <cdykes@fb.com>
Tue, 16 Aug 2016 23:27:28 +0000 (16:27 -0700)
committerFacebook Github Bot 4 <facebook-github-bot-4-bot@fb.com>
Tue, 16 Aug 2016 23:38:30 +0000 (16:38 -0700)
Summary:
The current implementation didn't work for MSVC, as it tries to evaluate `noexcept` expressions in base class lists before the template is instantiated.
`std::is_nothrow_swappable` is coming in C++17, and MSVC already has it, so use it instead.

Reviewed By: yfeldblum

Differential Revision: D3724399

fbshipit-source-id: 7927584618a7870824b2e7242fcae562647f4ef4

folly/Traits.h

index 3421d665754a249fc11815fcb41ddb4e8879fec4..fc3cba9c98827d100d8fc56b3609cc6324ca3d86 100644 (file)
@@ -159,6 +159,12 @@ 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.
+template <typename T>
+using IsNothrowSwappable = std::is_nothrow_swappable<T>;
+#else
 /* using override */ using std::swap;
 
 template <class T>
@@ -167,6 +173,7 @@ struct IsNothrowSwappable
         std::is_nothrow_move_constructible<T>::value &&
         noexcept(swap(std::declval<T&>(), std::declval<T&>()))
       > {};
+#endif
 }
 
 /* using override */ using traits_detail_IsNothrowSwappable::IsNothrowSwappable;