Commit edf5c731 authored by Orvid King's avatar Orvid King Committed by facebook-github-bot-1

Handle less_than_impl and greater_than_impl under MSVC

Summary: MSVC chokes on the template constraints of these functions, so use a single implementation that will be const-folded by the optimizer instead.
Closes https://github.com/facebook/folly/pull/281

Reviewed By: @yfeldblum

Differential Revision: D2419069

fb-gh-sync-id: c9ad3d135430f8265bbc90391b45d9295d6de362
parent 55f34d09
...@@ -320,67 +320,21 @@ struct is_negative_impl<T, false> { ...@@ -320,67 +320,21 @@ struct is_negative_impl<T, false> {
#pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-compare"
template <typename RHS, RHS rhs, typename LHS> template <typename RHS, RHS rhs, typename LHS>
bool less_than_impl( bool less_than_impl(LHS const lhs) {
typename std::enable_if< return
(rhs <= std::numeric_limits<LHS>::max() rhs > std::numeric_limits<LHS>::max() ? true :
&& rhs > std::numeric_limits<LHS>::min()), rhs <= std::numeric_limits<LHS>::min() ? false :
LHS lhs < rhs;
>::type const lhs
) {
return lhs < rhs;
}
template <typename RHS, RHS rhs, typename LHS>
bool less_than_impl(
typename std::enable_if<
(rhs > std::numeric_limits<LHS>::max()),
LHS
>::type const
) {
return true;
}
template <typename RHS, RHS rhs, typename LHS>
bool less_than_impl(
typename std::enable_if<
(rhs <= std::numeric_limits<LHS>::min()),
LHS
>::type const
) {
return false;
} }
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
template <typename RHS, RHS rhs, typename LHS> template <typename RHS, RHS rhs, typename LHS>
bool greater_than_impl( bool greater_than_impl(LHS const lhs) {
typename std::enable_if< return
(rhs <= std::numeric_limits<LHS>::max() rhs > std::numeric_limits<LHS>::max() ? false :
&& rhs >= std::numeric_limits<LHS>::min()), rhs < std::numeric_limits<LHS>::min() ? true :
LHS lhs > rhs;
>::type const lhs
) {
return lhs > rhs;
}
template <typename RHS, RHS rhs, typename LHS>
bool greater_than_impl(
typename std::enable_if<
(rhs > std::numeric_limits<LHS>::max()),
LHS
>::type const
) {
return false;
}
template <typename RHS, RHS rhs, typename LHS>
bool greater_than_impl(
typename std::enable_if<
(rhs < std::numeric_limits<LHS>::min()),
LHS
>::type const
) {
return true;
} }
} // namespace detail { } // namespace detail {
......
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