Commit 2fc030b4 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Avoid __forceinline for catch_exception under MSVC

Summary: [Folly] Avoid `__forceinline` for `catch_exception` under MSVC, which warns about functions which contain `try`-and-`catch` blcoks having the `__forceinline` modifier.

Reviewed By: akrieger

Differential Revision: D16982707

fbshipit-source-id: 68c443c4ce8ca77edd49d509a88ef4b0ab9488a9
parent 16b42cc0
......@@ -195,3 +195,16 @@
//
// Semantically includes the inline specifier.
#define FOLLY_ERASE FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN
// FOLLY_ERASE_TRYCATCH
//
// Equivalent to FOLLY_ERASE, but for code which might contain explicit
// exception handling. Has the effect of FOLLY_ERASE, except under MSVC which
// warns about __forceinline when functions contain exception handling.
//
// Semantically includes the inline specifier.
#ifdef _MSC_VER
#define FOLLY_ERASE_TRYCATCH inline
#else
#define FOLLY_ERASE_TRYCATCH FOLLY_ERASE
#endif
......@@ -181,7 +181,7 @@ template <typename F, typename... A>
/// def);
/// assert(result == input < 0 ? def : input);
template <typename E, typename Try, typename Catch, typename... CatchA>
FOLLY_ERASE auto catch_exception(Try&& t, Catch&& c, CatchA&&... a) ->
FOLLY_ERASE_TRYCATCH auto catch_exception(Try&& t, Catch&& c, CatchA&&... a) ->
typename std::common_type<
decltype(static_cast<Try&&>(t)()),
decltype(static_cast<Catch&&>(
......@@ -221,7 +221,7 @@ FOLLY_ERASE auto catch_exception(Try&& t, Catch&& c, CatchA&&... a) ->
/// def);
/// assert(result == input < 0 ? def : input);
template <typename Try, typename Catch, typename... CatchA>
FOLLY_ERASE auto catch_exception(Try&& t, Catch&& c, CatchA&&... a) ->
FOLLY_ERASE_TRYCATCH auto catch_exception(Try&& t, Catch&& c, CatchA&&... a) ->
typename std::common_type<
decltype(static_cast<Try&&>(t)()),
decltype(static_cast<Catch&&>(c)(static_cast<CatchA&&>(a)...))>::type {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment