Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 #include <limits> | 22 #include <limits> |
| 23 | 23 |
| 24 #include "base/logging.h" | 24 #include "base/logging.h" |
| 25 #include "util/stdlib/cxx.h" | 25 #include "util/stdlib/cxx.h" |
| 26 | 26 |
| 27 // CONSTEXPR_STATIC_ASSERT will be a normal static_assert if the C++ library is | 27 // CONSTEXPR_STATIC_ASSERT will be a normal static_assert if the C++ library is |
| 28 // the C++11 library. If using an older C++ library when compiling C++11 code, | 28 // the C++11 library. If using an older C++ library when compiling C++11 code, |
| 29 // the std::numeric_limits<>::min() and max() functions will not be marked as | 29 // the std::numeric_limits<>::min() and max() functions will not be marked as |
| 30 // constexpr, and thus won’t be usable with C++11’s static_assert(). In that | 30 // constexpr, and thus won’t be usable with C++11’s static_assert(). In that |
| 31 // case, a run-time CHECK() will have to do. | 31 // case, a run-time CHECK() will have to do. Visual Studio is nominally C++11, |
| 32 #if CXX_LIBRARY_VERSION >= 2011 | 32 // but does not fully support constexpr, so fall back to a CHECK. |
| 33 #if CXX_LIBRARY_VERSION >= 2011 && !defined(COMPILER_MSVC) | |
|
Mark Mentovai
2014/12/15 23:33:19
Maybe we should do this with a CXX_HAS_CONSTEXPR m
scottmg
2014/12/15 23:38:18
Done.
| |
| 33 #define CONSTEXPR_STATIC_ASSERT(condition, message) \ | 34 #define CONSTEXPR_STATIC_ASSERT(condition, message) \ |
| 34 static_assert(condition, message) | 35 static_assert(condition, message) |
| 35 #else | 36 #else |
| 36 #define CONSTEXPR_STATIC_ASSERT(condition, message) CHECK(condition) << message | 37 #define CONSTEXPR_STATIC_ASSERT(condition, message) CHECK(condition) << message |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 template <typename TIntType, typename TLongType> | 42 template <typename TIntType, typename TLongType> |
| 42 struct StringToIntegerTraits { | 43 struct StringToIntegerTraits { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 | 148 |
| 148 bool StringToNumber(const base::StringPiece& string, int* number) { | 149 bool StringToNumber(const base::StringPiece& string, int* number) { |
| 149 return StringToIntegerInternal<StringToIntTraits>(string, number); | 150 return StringToIntegerInternal<StringToIntTraits>(string, number); |
| 150 } | 151 } |
| 151 | 152 |
| 152 bool StringToNumber(const base::StringPiece& string, unsigned int* number) { | 153 bool StringToNumber(const base::StringPiece& string, unsigned int* number) { |
| 153 return StringToIntegerInternal<StringToUnsignedIntTraits>(string, number); | 154 return StringToIntegerInternal<StringToUnsignedIntTraits>(string, number); |
| 154 } | 155 } |
| 155 | 156 |
| 156 } // namespace crashpad | 157 } // namespace crashpad |
| OLD | NEW |