Commit ed118811 authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

Fix build on MSVC2015 Update 3

Summary: Which only supports C++11 style constepxr.

Reviewed By: simpkins

Differential Revision: D7546457

fbshipit-source-id: 52db98379096dd3b25f656e7e62238ce10537bf7
parent c0909b44
...@@ -52,14 +52,20 @@ constexpr_clamp(T const& v, T const& lo, T const& hi, Less less) { ...@@ -52,14 +52,20 @@ constexpr_clamp(T const& v, T const& lo, T const& hi, Less less) {
return less(v, lo) ? lo : less(hi, v) ? hi : v; return less(v, lo) ? lo : less(hi, v) ? hi : v;
} }
namespace detail {
// This can be replaced with std::less once everything we care about
// supports it.
template <typename T>
struct Less {
constexpr bool operator()(T const& a, T const& b) const {
return a < b;
}
};
} // namespace detail
template <typename T> template <typename T>
constexpr T const& constexpr_clamp(T const& v, T const& lo, T const& hi) { constexpr T const& constexpr_clamp(T const& v, T const& lo, T const& hi) {
struct Less { return constexpr_clamp(v, lo, hi, detail::Less<T>{});
constexpr bool operator()(T const& a, T const& b) const {
return a < b;
}
};
return constexpr_clamp(v, lo, hi, Less{});
} }
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