Changeset 199133 in webkit


Ignore:
Timestamp:
Apr 6, 2016 6:46:53 PM (8 years ago)
Author:
Simon Fraser
Message:

Fix Windows build by converting clampToInteger() into a template that only
takes integral types.

  • wtf/MathExtras.h:

(clampToInteger):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r199130 r199133  
     12016-04-06  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Fix Windows build by converting clampToInteger() into a template that only
     4        takes integral types.
     5
     6        * wtf/MathExtras.h:
     7        (clampToInteger):
     8
    192016-04-06  Simon Fraser  <simon.fraser@apple.com>
    210
  • trunk/Source/WTF/wtf/MathExtras.h

    r199130 r199133  
    182182}
    183183
    184 inline int clampToInteger(unsigned x)
    185 {
    186     const unsigned intMax = static_cast<unsigned>(std::numeric_limits<int>::max());
    187 
    188     if (x >= intMax)
    189         return std::numeric_limits<int>::max();
    190     return static_cast<int>(x);
    191 }
    192 
    193 inline int clampToInteger(size_t x)
    194 {
    195     const size_t intMax = static_cast<size_t>(std::numeric_limits<int>::max());
     184template<typename T>
     185inline int clampToInteger(T x)
     186{
     187    static_assert(std::numeric_limits<T>::is_integer, "T must be an integer.");
     188
     189    const T intMax = static_cast<unsigned>(std::numeric_limits<int>::max());
    196190
    197191    if (x >= intMax)
Note: See TracChangeset for help on using the changeset viewer.