From: Christopher Dykes Date: Thu, 13 Apr 2017 19:45:06 +0000 (-0700) Subject: Fix 1/2 of exception_wrapper under MSVC X-Git-Tag: v2017.04.17.00~21 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=8a56900338f3fccf82a35f5e4de9e9680abb05ad Fix 1/2 of exception_wrapper under MSVC 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 --- diff --git a/folly/ExceptionWrapper.cpp b/folly/ExceptionWrapper.cpp index c1440a57..0079db86 100644 --- a/folly/ExceptionWrapper.cpp +++ b/folly/ExceptionWrapper.cpp @@ -21,9 +21,32 @@ 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_, + &noop_, + &noop_, + &noop_, + &uninit_type_, + &noop_, + &noop_}; + +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 { diff --git a/folly/ExceptionWrapper.h b/folly/ExceptionWrapper.h index dcdf8628..9f734c5e 100644 --- a/folly/ExceptionWrapper.h +++ b/folly/ExceptionWrapper.h @@ -203,14 +203,7 @@ class exception_wrapper final { static std::type_info const* uninit_type_(exception_wrapper const*); - static constexpr VTable const uninit_{ - &noop_, - &noop_, - &noop_, - &noop_, - &uninit_type_, - &noop_, - &noop_}; + static VTable const uninit_; template using IsStdException = std::is_base_of>>; @@ -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 @@ -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 {