| Index: base/numerics/safe_conversions.h
|
| diff --git a/base/numerics/safe_conversions.h b/base/numerics/safe_conversions.h
|
| index e460039fc0894d33e8a228cc3ae9c2fe938fb1a9..b0ec279eb58551f9f792c18b43949951176083b3 100644
|
| --- a/base/numerics/safe_conversions.h
|
| +++ b/base/numerics/safe_conversions.h
|
| @@ -106,39 +106,7 @@ struct SaturationDefaultHandler {
|
|
|
| namespace internal {
|
|
|
| -template <typename T, template <typename> class S>
|
| -struct IsDefaultIntegralBounds {
|
| - static const bool value =
|
| - std::is_integral<T>::value &&
|
| - S<T>::max() == SaturationDefaultHandler<T>::max() &&
|
| - S<T>::lowest() == SaturationDefaultHandler<T>::lowest();
|
| -};
|
| -
|
| -// Integral to integral conversions have a special optimization for the
|
| -// standard bounds.
|
| -template <typename Dst,
|
| - template <typename> class S,
|
| - typename Src,
|
| - typename std::enable_if<
|
| - std::is_integral<Src>::value &&
|
| - IsDefaultIntegralBounds<Dst, S>::value>::type* = nullptr>
|
| -constexpr Dst saturated_cast_impl(Src value, RangeCheck constraint) {
|
| - using UnsignedDst = typename std::make_unsigned<Dst>::type;
|
| - // The member fields in this class are lined up such that the compiler
|
| - // can saturate without branching in this case by adding the register
|
| - // with the bitfields directly to the integral max.
|
| - return constraint.IsValid()
|
| - ? static_cast<Dst>(value)
|
| - : static_cast<Dst>(UnsignedDst(constraint.IsUnderflowFlagSet()) +
|
| - std::numeric_limits<Dst>::max());
|
| -}
|
| -
|
| -template <typename Dst,
|
| - template <typename> class S,
|
| - typename Src,
|
| - typename std::enable_if<
|
| - !std::is_integral<Src>::value ||
|
| - !IsDefaultIntegralBounds<Dst, S>::value>::type* = nullptr>
|
| +template <typename Dst, template <typename> class S, typename Src>
|
| constexpr Dst saturated_cast_impl(Src value, RangeCheck constraint) {
|
| // For some reason clang generates much better code when the branch is
|
| // structured exactly this way, rather than a sequence of checks.
|
|
|