Disable a couple of warnings for MSVC in folly::Function
authorChristopher Dykes <cdykes@fb.com>
Fri, 27 May 2016 16:48:20 +0000 (09:48 -0700)
committerFacebook Github Bot 1 <facebook-github-bot-1-bot@fb.com>
Fri, 27 May 2016 16:55:33 +0000 (09:55 -0700)
Summary:
MSVC generates warnings if you define multiple assignment operators or multiple copy constructors on the same type. This is deliberate in `folly::Function`, so just disable the warnings for the struct instead.
Note that the warnings have to be disabled for the entire struct for them to actually be disabled. Disabling them just around the declarations of the constructors and operators in question does not actually disable the warnings.

Reviewed By: yfeldblum

Differential Revision: D3347746

fbshipit-source-id: abb53a1e62bcfb7ce02759a7ce8637d824a82081

folly/Function.h

index a1b230e0d446f9cd0089a2fedd8de835ec9f72ee..aab8391cd746b440301b3d11ec683f7a6b9f464f 100644 (file)
 #include <utility>
 
 #include <folly/CppAttributes.h>
+#include <folly/Portability.h>
 
 namespace folly {
 
@@ -392,6 +393,9 @@ bool execBig(Op o, Data* src, Data* dst) {
 } // namespace function
 } // namespace detail
 
+FOLLY_PUSH_WARNING
+FOLLY_MSVC_DISABLE_WARNING(4521) // Multiple copy constructors
+FOLLY_MSVC_DISABLE_WARNING(4522) // Multiple assignment operators
 template <typename FunctionType>
 class Function final : private detail::function::FunctionTraits<FunctionType> {
   // These utility types are defined outside of the template to reduce
@@ -627,6 +631,7 @@ class Function final : private detail::function::FunctionTraits<FunctionType> {
     return Impl{std::make_shared<Function>(std::move(*this))};
   }
 };
+FOLLY_POP_WARNING
 
 template <typename FunctionType>
 void swap(Function<FunctionType>& lhs, Function<FunctionType>& rhs) noexcept {