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_ |
11 #define BASE_MACROS_H_ | 11 #define BASE_MACROS_H_ |
12 | 12 |
13 #include <stddef.h> // For size_t. | 13 #include <stddef.h> // For size_t. |
14 | 14 |
15 #include "build/build_config.h" // For OS_XXX. TODO(pkasting): Remove. | |
16 | |
17 // Put this in the declarations for a class to be uncopyable. | 15 // Put this in the declarations for a class to be uncopyable. |
18 #define DISALLOW_COPY(TypeName) \ | 16 #define DISALLOW_COPY(TypeName) \ |
19 TypeName(const TypeName&) = delete | 17 TypeName(const TypeName&) = delete |
20 | 18 |
21 // Put this in the declarations for a class to be unassignable. | 19 // Put this in the declarations for a class to be unassignable. |
22 #define DISALLOW_ASSIGN(TypeName) \ | 20 #define DISALLOW_ASSIGN(TypeName) \ |
23 void operator=(const TypeName&) = delete | 21 void operator=(const TypeName&) = delete |
24 | 22 |
25 // A macro to disallow the copy constructor and operator= functions. | 23 // A macro to disallow the copy constructor and operator= functions. |
26 // This should be used in the private: declarations for a class. | 24 // This should be used in the private: declarations for a class. |
27 // TODO(pkasting): Using "= delete" is Linux-specific initially to prevent | 25 // TODO(pkasting): Using "= delete" is non-branded-build-specific initially to |
28 // cross-platform code from regressing while other platforms are fixed. Remove | 26 // limit the rollout to reduce the chance of build breakage. Remove the ifdef |
29 // the ifdefs here and use "= delete" on all platforms. | 27 // here and use "= delete" always. |
30 #if defined(CHROMIUM_BUILD) && defined(OS_LINUX) && !defined(OS_CHROMEOS) | 28 #if defined(CHROMIUM_BUILD) |
31 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | 29 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
32 TypeName(const TypeName&) = delete; \ | 30 TypeName(const TypeName&) = delete; \ |
33 void operator=(const TypeName&) = delete | 31 void operator=(const TypeName&) = delete |
34 #else | 32 #else |
35 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | 33 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
36 TypeName(const TypeName&); \ | 34 TypeName(const TypeName&); \ |
37 void operator=(const TypeName&) | 35 void operator=(const TypeName&) |
38 #endif | 36 #endif |
39 | 37 |
40 // A macro to disallow all the implicit constructors, namely the | 38 // A macro to disallow all the implicit constructors, namely the |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 87 |
90 // Use these to declare and define a static local variable (static T;) so that | 88 // Use these to declare and define a static local variable (static T;) so that |
91 // it is leaked so that its destructors are not called at exit. If you need | 89 // it is leaked so that its destructors are not called at exit. If you need |
92 // thread-safe initialization, use base/lazy_instance.h instead. | 90 // thread-safe initialization, use base/lazy_instance.h instead. |
93 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ | 91 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ |
94 static type& name = *new type arguments | 92 static type& name = *new type arguments |
95 | 93 |
96 } // base | 94 } // base |
97 | 95 |
98 #endif // BASE_MACROS_H_ | 96 #endif // BASE_MACROS_H_ |
OLD | NEW |