From 30c4c2864581aa35359eb1aba09300698a383848 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Tue, 16 Aug 2016 16:27:28 -0700 Subject: [PATCH] Use std::is_nothrow_swappable under MSVC 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/folly/Traits.h b/folly/Traits.h index 3421d665..fc3cba9c 100644 --- a/folly/Traits.h +++ b/folly/Traits.h @@ -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 +using IsNothrowSwappable = std::is_nothrow_swappable; +#else /* using override */ using std::swap; template @@ -167,6 +173,7 @@ struct IsNothrowSwappable std::is_nothrow_move_constructible::value && noexcept(swap(std::declval(), std::declval())) > {}; +#endif } /* using override */ using traits_detail_IsNothrowSwappable::IsNothrowSwappable; -- 2.34.1