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

Unified Diff: util/stdlib/string_number_conversion.cc

Issue 615923004: Convert COMPILE_ASSERT to static_assert (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 3 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
Index: util/stdlib/string_number_conversion.cc
diff --git a/util/stdlib/string_number_conversion.cc b/util/stdlib/string_number_conversion.cc
index 76c80fdd5ec179f6b495122f4db9bf7c72e92c6f..b1a1f3dc089a642b3aec6d013db9f80da1d8ae33 100644
--- a/util/stdlib/string_number_conversion.cc
+++ b/util/stdlib/string_number_conversion.cc
@@ -32,7 +32,7 @@
// In that case, a run-time CHECK() will have to do.
#if CXX_LIBRARY_VERSION >= 2011
#define CONSTEXPR_COMPILE_ASSERT(condition, message) \
Mark Mentovai 2014/10/01 03:55:12 Probably you should rename this to CONSTEXPR_STATI
scottmg 2014/10/01 16:37:19 Done.
- COMPILE_ASSERT(condition, message)
+ static_assert(condition, #message)
#else
#define CONSTEXPR_COMPILE_ASSERT(condition, message) CHECK(condition)
Mark Mentovai 2014/10/01 03:55:12 You can make this CHECK(condition) << message, nuk
scottmg 2014/10/01 16:37:19 Done.
#endif
@@ -44,17 +44,17 @@ struct StringToIntegerTraits {
typedef TIntType IntType;
typedef TLongType LongType;
static void TypeCheck() {
- COMPILE_ASSERT(std::numeric_limits<TIntType>::is_integer &&
- std::numeric_limits<TLongType>::is_integer,
- IntType_and_LongType_must_be_integer);
- COMPILE_ASSERT(std::numeric_limits<TIntType>::is_signed ==
- std::numeric_limits<TLongType>::is_signed,
- IntType_and_LongType_signedness_must_agree);
+ static_assert(std::numeric_limits<TIntType>::is_integer &&
+ std::numeric_limits<TLongType>::is_integer,
+ "IntType and LongType must be integer");
+ static_assert(std::numeric_limits<TIntType>::is_signed ==
+ std::numeric_limits<TLongType>::is_signed,
+ "IntType and LongType signedness must agree");
CONSTEXPR_COMPILE_ASSERT(std::numeric_limits<TIntType>::min() >=
std::numeric_limits<TLongType>::min() &&
std::numeric_limits<TIntType>::min() <
std::numeric_limits<TLongType>::max(),
- IntType_min_must_be_in_LongType_range);
+ "IntType min must be in LongType range");
CONSTEXPR_COMPILE_ASSERT(std::numeric_limits<TIntType>::max() >
std::numeric_limits<TLongType>::min() &&
std::numeric_limits<TIntType>::max() <=
@@ -67,8 +67,8 @@ template <typename TIntType, typename TLongType>
struct StringToSignedIntegerTraits
: public StringToIntegerTraits<TIntType, TLongType> {
static void TypeCheck() {
- COMPILE_ASSERT(std::numeric_limits<TIntType>::is_signed,
- StringToSignedTraits_IntType_must_be_signed);
+ static_assert(std::numeric_limits<TIntType>::is_signed,
+ "StringToSignedTraits IntType must be signed");
return super::TypeCheck();
}
static bool IsNegativeOverflow(TLongType value) {
@@ -83,8 +83,8 @@ template <typename TIntType, typename TLongType>
struct StringToUnsignedIntegerTraits
: public StringToIntegerTraits<TIntType, TLongType> {
static void TypeCheck() {
- COMPILE_ASSERT(!std::numeric_limits<TIntType>::is_signed,
- StringToUnsignedTraits_IntType_must_be_unsigned);
+ static_assert(!std::numeric_limits<TIntType>::is_signed,
+ "StringToUnsignedTraits IntType must be unsigned");
return super::TypeCheck();
}
static bool IsNegativeOverflow(TLongType value) { return false; }

Powered by Google App Engine
This is Rietveld 408576698