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 23 matching lines...) Expand all Loading... |
34 // third_party libraries and get rid of it. | 34 // third_party libraries and get rid of it. |
35 #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) DISALLOW_COPY_AND_ASSIGN(TypeName) | 35 #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) DISALLOW_COPY_AND_ASSIGN(TypeName) |
36 | 36 |
37 // A macro to disallow all the implicit constructors, namely the | 37 // A macro to disallow all the implicit constructors, namely the |
38 // default constructor, copy constructor and operator= functions. | 38 // default constructor, copy constructor and operator= functions. |
39 // | 39 // |
40 // This should be used in the private: declarations for a class | 40 // This should be used in the private: declarations for a class |
41 // that wants to prevent anyone from instantiating it. This is | 41 // that wants to prevent anyone from instantiating it. This is |
42 // especially useful for classes containing only static methods. | 42 // especially useful for classes containing only static methods. |
43 #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ | 43 #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ |
44 TypeName(); \ | 44 TypeName() = delete; \ |
45 DISALLOW_COPY_AND_ASSIGN(TypeName) | 45 DISALLOW_COPY_AND_ASSIGN(TypeName) |
46 | 46 |
47 // The arraysize(arr) macro returns the # of elements in an array arr. | 47 // The arraysize(arr) macro returns the # of elements in an array arr. |
48 // The expression is a compile-time constant, and therefore can be | 48 // The expression is a compile-time constant, and therefore can be |
49 // used in defining new arrays, for example. If you use arraysize on | 49 // used in defining new arrays, for example. If you use arraysize on |
50 // a pointer by mistake, you will get a compile-time error. | 50 // a pointer by mistake, you will get a compile-time error. |
51 | 51 |
52 // This template function declaration is used in defining arraysize. | 52 // This template function declaration is used in defining arraysize. |
53 // Note that the function doesn't need an implementation, as we only | 53 // Note that the function doesn't need an implementation, as we only |
54 // use its type. | 54 // use its type. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 // Use these to declare and define a static local variable (static T;) so that | 190 // Use these to declare and define a static local variable (static T;) so that |
191 // it is leaked so that its destructors are not called at exit. If you need | 191 // it is leaked so that its destructors are not called at exit. If you need |
192 // thread-safe initialization, use base/lazy_instance.h instead. | 192 // thread-safe initialization, use base/lazy_instance.h instead. |
193 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ | 193 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ |
194 static type& name = *new type arguments | 194 static type& name = *new type arguments |
195 | 195 |
196 } // base | 196 } // base |
197 | 197 |
198 #endif // BASE_MACROS_H_ | 198 #endif // BASE_MACROS_H_ |
OLD | NEW |