use std::underlying_type

Change-Id: If05a8e99c5754859a2b04f040097eff3461a42e6
Reviewed-on: https://skia-review.googlesource.com/c/189220
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2019-02-04 10:03:04 -05:00 committed by Skia Commit-Bot
parent 88e58a7912
commit c3b4790332
2 changed files with 2 additions and 24 deletions

View File

@ -14,7 +14,7 @@ template <typename T> struct is_bitmask_enum : std::false_type {};
}
template <typename E> SK_WHEN(skstd::is_bitmask_enum<E>::value, E) operator|(E l, E r) {
using U = skstd::underlying_type_t<E>;
using U = typename std::underlying_type<E>::type;
return static_cast<E>(static_cast<U>(l) | static_cast<U>(r));
}
@ -23,7 +23,7 @@ template <typename E> SK_WHEN(skstd::is_bitmask_enum<E>::value, E&) operator|=(E
}
template <typename E> SK_WHEN(skstd::is_bitmask_enum<E>::value, E) operator&(E l, E r) {
using U = skstd::underlying_type_t<E>;
using U = typename std::underlying_type<E>::type;
return static_cast<E>(static_cast<U>(l) & static_cast<U>(r));
}

View File

@ -44,28 +44,6 @@ template <typename T> using result_of_t = typename std::result_of<T>::type;
template <typename... T> using common_type_t = typename std::common_type<T...>::type;
// Chromium currently requires gcc 4.8.2 or a recent clang compiler, but uses libstdc++4.6.4.
// Note that Precise actually uses libstdc++4.6.3.
// Unfortunately, libstdc++ STL before libstdc++4.7 do not define std::underlying_type.
// Newer gcc and clang compilers have __underlying_type which does not depend on runtime support.
// See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html for __GLIBCXX__ values.
// Unfortunately __GLIBCXX__ is a date, but no updates to versions before 4.7 are now anticipated.
#define SK_GLIBCXX_4_7_0 20120322
// Updates to versions before 4.7 but released after 4.7 was released.
#define SK_GLIBCXX_4_5_4 20120702
#define SK_GLIBCXX_4_6_4 20121127
#if defined(__GLIBCXX__) && (__GLIBCXX__ < SK_GLIBCXX_4_7_0 || \
__GLIBCXX__ == SK_GLIBCXX_4_5_4 || \
__GLIBCXX__ == SK_GLIBCXX_4_6_4)
template <typename T> struct underlying_type {
using type = __underlying_type(T);
};
#else
template <typename T> using underlying_type = std::underlying_type<T>;
#endif
template <typename T> using underlying_type_t = typename skstd::underlying_type<T>::type;
template <std::size_t... Ints> struct index_sequence {
using type = index_sequence;
using value_type = size_t;