Commit c8fc4f2d authored by Eugeny Aristov's avatar Eugeny Aristov Committed by Commit Bot

GCC: Fix template parameters order

For GCC it's important, otherwise in this specific case
std::underlying_type is taken for incompatible types
(int, char, etc.) before std::enable_if_t throws out
inproper template.

Error example (GCC 8.4.0):
/usr/include/c++/8/type_traits: In instantiation of
'struct std::underlying_type<long unsigned int>':
../third_party/blink/public/common/privacy_budget/identifiable_token.h:121:13:
../chrome/browser/privacy_budget/privacy_budget_ukm_entry_filter.cc:61:73:
required from here /usr/include/c++/8/type_traits:2009:38:
error: 'long unsigned int' is not an enumeration type

Bug: 819294
Change-Id: Ic4b329d12ca2c8899e62c65b2a327b227caa2c38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2480442Reviewed-by: default avatarAsanka Herath <asanka@chromium.org>
Commit-Queue: Asanka Herath <asanka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818749}
parent bf73bd94
...@@ -118,8 +118,9 @@ class IdentifiableToken { ...@@ -118,8 +118,9 @@ class IdentifiableToken {
// Enums. Punt to the underlying type. // Enums. Punt to the underlying type.
template <typename T, template <typename T,
typename U = typename std::underlying_type<T>::type, // Set dummy type before U to avoid GCC compile errors
typename std::enable_if_t<std::is_enum<T>::value>* = nullptr> typename std::enable_if_t<std::is_enum<T>::value>* = nullptr,
typename U = typename std::underlying_type<T>::type>
constexpr IdentifiableToken(T in) // NOLINT(google-explicit-constructor) constexpr IdentifiableToken(T in) // NOLINT(google-explicit-constructor)
: IdentifiableToken(static_cast<U>(in)) {} : IdentifiableToken(static_cast<U>(in)) {}
......
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