| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file contains macros and macro-like constructs (e.g., templates) that | 5 // This file contains macros and macro-like constructs (e.g., templates) that |
| 6 // are commonly used throughout Chromium source. (It may also contain things | 6 // are commonly used throughout Chromium source. (It may also contain things |
| 7 // that are closely related to things that are commonly used that belong in this | 7 // that are closely related to things that are commonly used that belong in this |
| 8 // file.) | 8 // file.) |
| 9 | 9 |
| 10 #ifndef BASE_MACROS_H_ | 10 #ifndef BASE_MACROS_H_ |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 char (&ArraySizeHelper(T (&array)[N]))[N]; | 56 char (&ArraySizeHelper(T (&array)[N]))[N]; |
| 57 | 57 |
| 58 // That gcc wants both of these prototypes seems mysterious. VC, for | 58 // That gcc wants both of these prototypes seems mysterious. VC, for |
| 59 // its part, can't decide which to use (another mystery). Matching of | 59 // its part, can't decide which to use (another mystery). Matching of |
| 60 // template overloads: the final frontier. | 60 // template overloads: the final frontier. |
| 61 #ifndef _MSC_VER | 61 #ifndef _MSC_VER |
| 62 template <typename T, size_t N> | 62 template <typename T, size_t N> |
| 63 char (&ArraySizeHelper(const T (&array)[N]))[N]; | 63 char (&ArraySizeHelper(const T (&array)[N]))[N]; |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 #define arraysize(array) (sizeof(ArraySizeHelper(array))) | 66 #define arraysize(array) (sizeof(::ArraySizeHelper(array))) |
| 67 | 67 |
| 68 | 68 |
| 69 // Use implicit_cast as a safe version of static_cast or const_cast | 69 // Use implicit_cast as a safe version of static_cast or const_cast |
| 70 // for upcasting in the type hierarchy (i.e. casting a pointer to Foo | 70 // for upcasting in the type hierarchy (i.e. casting a pointer to Foo |
| 71 // to a pointer to SuperclassOfFoo or casting a pointer to Foo to | 71 // to a pointer to SuperclassOfFoo or casting a pointer to Foo to |
| 72 // a const pointer to Foo). | 72 // a const pointer to Foo). |
| 73 // When you use implicit_cast, the compiler checks that the cast is safe. | 73 // When you use implicit_cast, the compiler checks that the cast is safe. |
| 74 // Such explicit implicit_casts are necessary in surprisingly many | 74 // Such explicit implicit_casts are necessary in surprisingly many |
| 75 // situations where C++ demands an exact type match instead of an | 75 // situations where C++ demands an exact type match instead of an |
| 76 // argument type convertible to a target type. | 76 // argument type convertible to a target type. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 199 |
| 200 // Use these to declare and define a static local variable (static T;) so that | 200 // Use these to declare and define a static local variable (static T;) so that |
| 201 // it is leaked so that its destructors are not called at exit. If you need | 201 // it is leaked so that its destructors are not called at exit. If you need |
| 202 // thread-safe initialization, use base/lazy_instance.h instead. | 202 // thread-safe initialization, use base/lazy_instance.h instead. |
| 203 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ | 203 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ |
| 204 static type& name = *new type arguments | 204 static type& name = *new type arguments |
| 205 | 205 |
| 206 } // base | 206 } // base |
| 207 | 207 |
| 208 #endif // BASE_MACROS_H_ | 208 #endif // BASE_MACROS_H_ |
| OLD | NEW |