| Index: base/template_util.h
|
| diff --git a/base/template_util.h b/base/template_util.h
|
| index 1bfc1ac814a23ceb186a9fcf6fa5924281d92783..af4cdd5a21c4993dca662b7c717dfcc25b7f1714 100644
|
| --- a/base/template_util.h
|
| +++ b/base/template_util.h
|
| @@ -29,6 +29,20 @@ template <class T> struct is_non_const_reference : std::false_type {};
|
| template <class T> struct is_non_const_reference<T&> : std::true_type {};
|
| template <class T> struct is_non_const_reference<const T&> : std::false_type {};
|
|
|
| +// underlying_number
|
| +// Casts an enum to its underlying integral type, leaves other numbers alone.
|
| +// Useful for scoped enums, which don't cast implicitly.
|
| +template <typename T,
|
| + typename std::enable_if<std::is_enum<T>::value, int>::type = 0>
|
| +constexpr typename std::underlying_type<T>::type underlying_number(T val) {
|
| + return static_cast<typename std::underlying_type<T>::type>(val);
|
| +}
|
| +template <typename T,
|
| + typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
| +constexpr T underlying_number(T val) {
|
| + return val;
|
| +}
|
| +
|
| // is_assignable
|
|
|
| namespace internal {
|
|
|