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

Side by Side Diff: util/stdlib/string_number_conversion.cc

Issue 809833002: string_number_conversions: only check CXX_LIBRARY_HAS_CONSTEXPR (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/stdlib/string_number_conversion.h" 15 #include "util/stdlib/string_number_conversion.h"
16 16
17 #include <ctype.h> 17 #include <ctype.h>
18 #include <errno.h> 18 #include <errno.h>
19 #include <stdlib.h> 19 #include <stdlib.h>
20 #include <string.h> 20 #include <string.h>
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, the
29 // the std::numeric_limits<>::min() and max() functions will not be marked as 29 // 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 static_assert(). In that case, a
31 // case, a run-time CHECK() will have to do. 31 // run-time CHECK() will have to do.
32 #if CXX_LIBRARY_VERSION >= 2011 && CXX_LIBRARY_HAS_CONSTEXPR 32 #if CXX_LIBRARY_HAS_CONSTEXPR
33 #define CONSTEXPR_STATIC_ASSERT(condition, message) \ 33 #define CONSTEXPR_STATIC_ASSERT(condition, message) \
34 static_assert(condition, message) 34 static_assert(condition, message)
35 #else 35 #else
36 #define CONSTEXPR_STATIC_ASSERT(condition, message) CHECK(condition) << message 36 #define CONSTEXPR_STATIC_ASSERT(condition, message) CHECK(condition) << message
37 #endif 37 #endif
38 38
39 namespace { 39 namespace {
40 40
41 template <typename TIntType, typename TLongType> 41 template <typename TIntType, typename TLongType>
42 struct StringToIntegerTraits { 42 struct StringToIntegerTraits {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 bool StringToNumber(const base::StringPiece& string, int* number) { 148 bool StringToNumber(const base::StringPiece& string, int* number) {
149 return StringToIntegerInternal<StringToIntTraits>(string, number); 149 return StringToIntegerInternal<StringToIntTraits>(string, number);
150 } 150 }
151 151
152 bool StringToNumber(const base::StringPiece& string, unsigned int* number) { 152 bool StringToNumber(const base::StringPiece& string, unsigned int* number) {
153 return StringToIntegerInternal<StringToUnsignedIntTraits>(string, number); 153 return StringToIntegerInternal<StringToUnsignedIntTraits>(string, number);
154 } 154 }
155 155
156 } // namespace crashpad 156 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698