| Index: third_party/numerics/safe_conversions_impl.h
|
| diff --git a/third_party/numerics/safe_conversions_impl.h b/third_party/numerics/safe_conversions_impl.h
|
| index a357e518d1f5fcd0211177fa7cdacce5862eecb6..62851ff4a9fb897824b382735bdc133e104b5a53 100644
|
| --- a/third_party/numerics/safe_conversions_impl.h
|
| +++ b/third_party/numerics/safe_conversions_impl.h
|
| @@ -42,17 +42,16 @@ enum NumericRangeRepresentation {
|
| // Helper templates to statically determine if our destination type can contain
|
| // maximum and minimum values represented by the source type.
|
|
|
| -template <
|
| - typename Dst,
|
| - typename Src,
|
| - IntegerRepresentation DstSign = std::numeric_limits<Dst>::is_signed
|
| - ? INTEGER_REPRESENTATION_SIGNED
|
| - : INTEGER_REPRESENTATION_UNSIGNED,
|
| - IntegerRepresentation SrcSign =
|
| - std::numeric_limits<Src>::is_signed
|
| - ? INTEGER_REPRESENTATION_SIGNED
|
| - : INTEGER_REPRESENTATION_UNSIGNED >
|
| -struct StaticDstRangeRelationToSrcRange;
|
| +template <typename Dst,
|
| + typename Src,
|
| + IntegerRepresentation DstSign = std::numeric_limits<Dst>::is_signed
|
| + ? INTEGER_REPRESENTATION_SIGNED
|
| + : INTEGER_REPRESENTATION_UNSIGNED,
|
| + IntegerRepresentation SrcSign =
|
| + std::numeric_limits<Src>::is_signed
|
| + ? INTEGER_REPRESENTATION_SIGNED
|
| + : INTEGER_REPRESENTATION_UNSIGNED >
|
| + struct StaticDstRangeRelationToSrcRange;
|
|
|
| // Same sign: Dst is guaranteed to contain Src only if its range is equal or
|
| // larger.
|
| @@ -87,9 +86,9 @@ struct StaticDstRangeRelationToSrcRange<Dst,
|
| };
|
|
|
| enum RangeConstraint {
|
| - RANGE_VALID = 0x0, // Value can be represented by the destination type.
|
| + RANGE_VALID = 0x0, // Value can be represented by the destination type.
|
| RANGE_UNDERFLOW = 0x1, // Value would overflow.
|
| - RANGE_OVERFLOW = 0x2, // Value would underflow.
|
| + RANGE_OVERFLOW = 0x2, // Value would underflow.
|
| RANGE_INVALID = RANGE_UNDERFLOW | RANGE_OVERFLOW // Invalid (i.e. NaN).
|
| };
|
|
|
| @@ -104,23 +103,23 @@ inline RangeConstraint GetRangeConstraint(int integer_range_constraint) {
|
| // check by taking advantage of the fact that only NaN can be out of range in
|
| // both directions at once.
|
| inline RangeConstraint GetRangeConstraint(bool is_in_upper_bound,
|
| - bool is_in_lower_bound) {
|
| + bool is_in_lower_bound) {
|
| return GetRangeConstraint((is_in_upper_bound ? 0 : RANGE_OVERFLOW) |
|
| (is_in_lower_bound ? 0 : RANGE_UNDERFLOW));
|
| }
|
|
|
| -template <
|
| - typename Dst,
|
| - typename Src,
|
| - IntegerRepresentation DstSign = std::numeric_limits<Dst>::is_signed
|
| - ? INTEGER_REPRESENTATION_SIGNED
|
| - : INTEGER_REPRESENTATION_UNSIGNED,
|
| - IntegerRepresentation SrcSign = std::numeric_limits<Src>::is_signed
|
| - ? INTEGER_REPRESENTATION_SIGNED
|
| - : INTEGER_REPRESENTATION_UNSIGNED,
|
| - NumericRangeRepresentation DstRange =
|
| - StaticDstRangeRelationToSrcRange<Dst, Src>::value >
|
| -struct DstRangeRelationToSrcRangeImpl;
|
| +template <typename Dst,
|
| + typename Src,
|
| + IntegerRepresentation DstSign = std::numeric_limits<Dst>::is_signed
|
| + ? INTEGER_REPRESENTATION_SIGNED
|
| + : INTEGER_REPRESENTATION_UNSIGNED,
|
| + IntegerRepresentation
|
| + SrcSign = std::numeric_limits<Src>::is_signed
|
| + ? INTEGER_REPRESENTATION_SIGNED
|
| + : INTEGER_REPRESENTATION_UNSIGNED,
|
| + NumericRangeRepresentation DstRange =
|
| + StaticDstRangeRelationToSrcRange<Dst, Src>::value >
|
| + struct DstRangeRelationToSrcRangeImpl;
|
|
|
| // The following templates are for ranges that must be verified at runtime. We
|
| // split it into checks based on signedness to avoid confusing casts and
|
| @@ -214,4 +213,3 @@ inline RangeConstraint DstRangeRelationToSrcRange(Src value) {
|
| } // namespace base
|
|
|
| #endif // BASE_SAFE_CONVERSIONS_IMPL_H_
|
| -
|
|
|