Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1021)

Unified Diff: base/metrics/histogram_macros_internal.h

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: simplify type checking Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/histogram_functions_unittest.cc ('k') | base/metrics/histogram_unittest.nc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram_macros_internal.h
diff --git a/base/metrics/histogram_macros_internal.h b/base/metrics/histogram_macros_internal.h
index c107a4729d26243d6e81d510e03fb769abb137aa..1bc68c6cac3ef71a68453219787d3ca217b3b03e 100644
--- a/base/metrics/histogram_macros_internal.h
+++ b/base/metrics/histogram_macros_internal.h
@@ -140,10 +140,14 @@
#define INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary, flag) \
do { \
static_assert( \
- !std::is_enum<decltype(sample)>::value || \
- !std::is_enum<decltype(boundary)>::value || \
- std::is_same<std::remove_const<decltype(sample)>::type, \
- std::remove_const<decltype(boundary)>::type>::value, \
+ !std::is_enum<std::decay<decltype(boundary)>::type>::value || \
+ std::is_enum<std::decay<decltype(sample)>::type>::value, \
+ "Unexpected: |boundary| is enum, but |sample| is not."); \
+ static_assert( \
+ !std::is_enum<std::decay<decltype(sample)>::type>::value || \
+ !std::is_enum<std::decay<decltype(boundary)>::type>::value || \
+ std::is_same<std::decay<decltype(sample)>::type, \
+ std::decay<decltype(boundary)>::type>::value, \
"|sample| and |boundary| shouldn't be of different enums"); \
static_assert( \
static_cast<uintmax_t>(boundary) < \
« no previous file with comments | « base/metrics/histogram_functions_unittest.cc ('k') | base/metrics/histogram_unittest.nc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698