OLD | NEW |
1 // Copyright 2009 The RE2 Authors. All Rights Reserved. | 1 // Copyright 2009 The RE2 Authors. All Rights Reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RE2_UTIL_UTIL_H__ | 5 #ifndef RE2_UTIL_UTIL_H__ |
6 #define RE2_UTIL_UTIL_H__ | 6 #define RE2_UTIL_UTIL_H__ |
7 | 7 |
8 // C | 8 // C |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 typedef int32_t int32; | 72 typedef int32_t int32; |
73 typedef uint32_t uint32; | 73 typedef uint32_t uint32; |
74 typedef int64_t int64; | 74 typedef int64_t int64; |
75 typedef uint64_t uint64; | 75 typedef uint64_t uint64; |
76 | 76 |
77 typedef unsigned long ulong; | 77 typedef unsigned long ulong; |
78 typedef unsigned int uint; | 78 typedef unsigned int uint; |
79 typedef unsigned short ushort; | 79 typedef unsigned short ushort; |
80 | 80 |
81 // COMPILE_ASSERT causes a compile error about msg if expr is not true. | 81 // COMPILE_ASSERT causes a compile error about msg if expr is not true. |
| 82 #if __cplusplus >= 201103L |
| 83 #define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg) |
| 84 #else |
82 template<bool> struct CompileAssert {}; | 85 template<bool> struct CompileAssert {}; |
83 #define COMPILE_ASSERT(expr, msg) \ | 86 #define COMPILE_ASSERT(expr, msg) \ |
84 typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] | 87 typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] |
| 88 #endif |
85 | 89 |
86 // DISALLOW_EVIL_CONSTRUCTORS disallows the copy and operator= functions. | 90 // DISALLOW_EVIL_CONSTRUCTORS disallows the copy and operator= functions. |
87 // It goes in the private: declarations in a class. | 91 // It goes in the private: declarations in a class. |
88 #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ | 92 #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ |
89 TypeName(const TypeName&); \ | 93 TypeName(const TypeName&); \ |
90 void operator=(const TypeName&) | 94 void operator=(const TypeName&) |
91 | 95 |
92 #define arraysize(array) (sizeof(array)/sizeof((array)[0])) | 96 #define arraysize(array) (sizeof(array)/sizeof((array)[0])) |
93 | 97 |
94 // Fake lock annotations. For real ones, see | 98 // Fake lock annotations. For real ones, see |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 142 } |
139 | 143 |
140 } // namespace re2 | 144 } // namespace re2 |
141 | 145 |
142 #include "util/arena.h" | 146 #include "util/arena.h" |
143 #include "util/logging.h" | 147 #include "util/logging.h" |
144 #include "util/mutex.h" | 148 #include "util/mutex.h" |
145 #include "util/utf.h" | 149 #include "util/utf.h" |
146 | 150 |
147 #endif // RE2_UTIL_UTIL_H__ | 151 #endif // RE2_UTIL_UTIL_H__ |
OLD | NEW |