Skip to content
Permalink
Browse files
Change CheckedArithmetic to not use std::enable_if_t.
https://bugs.webkit.org/show_bug.cgi?id=195187
<rdar://problem/48464665>

Reviewed by Keith Miller.

Because C++11 does not like std::enable_if_t and there's a need to use this file with C++11.

* wtf/CheckedArithmetic.h:



Canonical link: https://commits.webkit.org/209517@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242235 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Mark Lam committed Feb 28, 2019
1 parent 88a3e10 commit 60767e65ec86cc9ed2ade1647b93fd4205911b8f
Showing 2 changed files with 16 additions and 4 deletions.
@@ -1,3 +1,15 @@
2019-02-28 Mark Lam <mark.lam@apple.com>

Change CheckedArithmetic to not use std::enable_if_t.
https://bugs.webkit.org/show_bug.cgi?id=195187
<rdar://problem/48464665>

Reviewed by Keith Miller.

Because C++11 does not like std::enable_if_t and there's a need to use this file with C++11.

* wtf/CheckedArithmetic.h:

2019-02-27 Simon Fraser <simon.fraser@apple.com>

Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141)
@@ -541,7 +541,7 @@ template <typename ResultType> struct ArithmeticOperations<unsigned, int, Result
}
};

template <class OverflowHandler, typename = std::enable_if_t<!std::is_scalar<OverflowHandler>::value>>
template <class OverflowHandler, typename = typename std::enable_if<!std::is_scalar<OverflowHandler>::value>::type>
inline constexpr bool observesOverflow() { return true; }

template <>
@@ -553,7 +553,7 @@ template <typename U, typename V, typename R> static inline bool safeAdd(U lhs,
return true;
}

template <class OverflowHandler, typename U, typename V, typename R, typename = std::enable_if_t<!std::is_scalar<OverflowHandler>::value>>
template <class OverflowHandler, typename U, typename V, typename R, typename = typename std::enable_if<!std::is_scalar<OverflowHandler>::value>::type>
static inline bool safeAdd(U lhs, V rhs, R& result)
{
if (observesOverflow<OverflowHandler>())
@@ -567,7 +567,7 @@ template <typename U, typename V, typename R> static inline bool safeSub(U lhs,
return ArithmeticOperations<U, V, R>::sub(lhs, rhs, result);
}

template <class OverflowHandler, typename U, typename V, typename R, typename = std::enable_if_t<!std::is_scalar<OverflowHandler>::value>>
template <class OverflowHandler, typename U, typename V, typename R, typename = typename std::enable_if<!std::is_scalar<OverflowHandler>::value>::type>
static inline bool safeSub(U lhs, V rhs, R& result)
{
if (observesOverflow<OverflowHandler>())
@@ -581,7 +581,7 @@ template <typename U, typename V, typename R> static inline bool safeMultiply(U
return ArithmeticOperations<U, V, R>::multiply(lhs, rhs, result);
}

template <class OverflowHandler, typename U, typename V, typename R, typename = std::enable_if_t<!std::is_scalar<OverflowHandler>::value>>
template <class OverflowHandler, typename U, typename V, typename R, typename = typename std::enable_if<!std::is_scalar<OverflowHandler>::value>::type>
static inline bool safeMultiply(U lhs, V rhs, R& result)
{
if (observesOverflow<OverflowHandler>())

0 comments on commit 60767e6

Please sign in to comment.