Fix 1/2 of exception_wrapper under MSVC
authorChristopher Dykes <cdykes@fb.com>
Thu, 13 Apr 2017 19:45:06 +0000 (12:45 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 13 Apr 2017 19:58:58 +0000 (12:58 -0700)
Summary:
MSVC didn't like referring to members of `exception_wrapper` in the initializer for a `static constexpr` field directly in `exception_wrapper`, so shift the initialization to the actual definition of the fields.
As the fields are only referred to via their address, dropping the `constexpr` loses nothing.

Reviewed By: ericniebler

Differential Revision: D4873939

fbshipit-source-id: 30b690b1ab3f2f7a25b9dc4863b46f64c811797d

folly/ExceptionWrapper.cpp
folly/ExceptionWrapper.h

index c1440a57a40a9f67d84d8301ba4babd081560be6..0079db866d7160f368b869983e22370c3210109c 100644 (file)
 
 namespace folly {
 
-constexpr exception_wrapper::VTable const exception_wrapper::uninit_;
-constexpr exception_wrapper::VTable const exception_wrapper::ExceptionPtr::ops_;
-constexpr exception_wrapper::VTable const exception_wrapper::SharedPtr::ops_;
+exception_wrapper::VTable const exception_wrapper::uninit_{
+    &noop_<void, exception_wrapper const*, exception_wrapper*>,
+    &noop_<void, exception_wrapper*, exception_wrapper*>,
+    &noop_<void, exception_wrapper*>,
+    &noop_<void, exception_wrapper const*>,
+    &uninit_type_,
+    &noop_<std::exception const*, exception_wrapper const*>,
+    &noop_<exception_wrapper, exception_wrapper const*>};
+
+exception_wrapper::VTable const exception_wrapper::ExceptionPtr::ops_{
+    copy_,
+    move_,
+    delete_,
+    throw_,
+    type_,
+    get_exception_,
+    get_exception_ptr_};
+
+exception_wrapper::VTable const exception_wrapper::SharedPtr::ops_{
+    copy_,
+    move_,
+    delete_,
+    throw_,
+    type_,
+    get_exception_,
+    get_exception_ptr_};
 
 namespace {
 std::exception const* get_std_exception_(std::exception_ptr eptr) noexcept {
index dcdf862870863c25585415d15497505f01c4f5fc..9f734c5e8a738e0619becdcd8f334c1ad660f9b5 100644 (file)
@@ -203,14 +203,7 @@ class exception_wrapper final {
 
   static std::type_info const* uninit_type_(exception_wrapper const*);
 
-  static constexpr VTable const uninit_{
-      &noop_<void, exception_wrapper const*, exception_wrapper*>,
-      &noop_<void, exception_wrapper*, exception_wrapper*>,
-      &noop_<void, exception_wrapper*>,
-      &noop_<void, exception_wrapper const*>,
-      &uninit_type_,
-      &noop_<std::exception const*, exception_wrapper const*>,
-      &noop_<exception_wrapper, exception_wrapper const*>};
+  static VTable const uninit_;
 
   template <class Ex>
   using IsStdException = std::is_base_of<std::exception, _t<std::decay<Ex>>>;
@@ -277,13 +270,7 @@ class exception_wrapper final {
     static std::type_info const* type_(exception_wrapper const* that);
     static std::exception const* get_exception_(exception_wrapper const* that);
     static exception_wrapper get_exception_ptr_(exception_wrapper const* that);
-    static constexpr VTable const ops_{copy_,
-                                       move_,
-                                       delete_,
-                                       throw_,
-                                       type_,
-                                       get_exception_,
-                                       get_exception_ptr_};
+    static VTable const ops_;
   };
 
   template <class Ex>
@@ -334,13 +321,7 @@ class exception_wrapper final {
     static std::type_info const* type_(exception_wrapper const* that);
     static std::exception const* get_exception_(exception_wrapper const* that);
     static exception_wrapper get_exception_ptr_(exception_wrapper const* that);
-    static constexpr VTable ops_{copy_,
-                                 move_,
-                                 delete_,
-                                 throw_,
-                                 type_,
-                                 get_exception_,
-                                 get_exception_ptr_};
+    static VTable const ops_;
   };
 
   union {