Commit 92c4c7e2 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Rename to_underlying_type to to_underlying

Summary:
[Folly] Rename `to_underlying_type` to `to_underlying`, following the pattern of `to_unsigned` and `to_signed`.

(Note: this ignores all push blocking failures!)

Reviewed By: mzlee

Differential Revision: D15776448

fbshipit-source-id: d1f87e917c22a1aa47fb5e37a3ecf7032cec0d48
parent 9b9aadfc
......@@ -650,13 +650,13 @@ template <class Tgt, class Src>
typename std::enable_if<
std::is_enum<Src>::value && IsSomeString<Tgt>::value>::type
toAppend(Src value, Tgt* result) {
toAppend(to_underlying_type(value), result);
toAppend(to_underlying(value), result);
}
template <class Src>
typename std::enable_if<std::is_enum<Src>::value, size_t>::type
estimateSpaceNeeded(Src value) {
return estimateSpaceNeeded(to_underlying_type(value));
return estimateSpaceNeeded(to_underlying(value));
}
/*******************************************************************************
......@@ -1547,7 +1547,7 @@ typename std::enable_if<
!std::is_convertible<Tgt, StringPiece>::value,
Expected<Tgt, ConversionCode>>::type
tryTo(const Src& value) {
return tryTo<Tgt>(to_underlying_type(value));
return tryTo<Tgt>(to_underlying(value));
}
template <class Tgt, class Src>
......@@ -1566,7 +1566,7 @@ typename std::enable_if<
!std::is_convertible<Tgt, StringPiece>::value,
Tgt>::type
to(const Src& value) {
return to<Tgt>(to_underlying_type(value));
return to<Tgt>(to_underlying(value));
}
template <class Tgt, class Src>
......
......@@ -335,7 +335,7 @@ struct DynamicConstructor<
C,
typename std::enable_if<std::is_enum<C>::value>::type> {
static dynamic construct(const C& x) {
return dynamic(to_underlying_type(x));
return dynamic(to_underlying(x));
}
};
......
......@@ -306,7 +306,7 @@ constexpr auto to_unsigned(T const& t) -> typename std::make_unsigned<T>::type {
}
template <class E>
constexpr std::underlying_type_t<E> to_underlying_type(E e) noexcept {
constexpr std::underlying_type_t<E> to_underlying(E e) noexcept {
static_assert(std::is_enum<E>::value, "not an enum type");
return static_cast<std::underlying_type_t<E>>(e);
}
......
......@@ -510,7 +510,7 @@ struct IsAvalanchingHasher<hasher<std::string>, K> : std::true_type {};
template <typename T>
struct hasher<T, std::enable_if_t<std::is_enum<T>::value>> {
size_t operator()(T key) const noexcept {
return Hash()(to_underlying_type(key));
return Hash()(to_underlying(key));
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment