OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_BASE_CONSTRUCTORMAGIC_H_ | 11 #ifndef WEBRTC_BASE_CONSTRUCTORMAGIC_H_ |
12 #define WEBRTC_BASE_CONSTRUCTORMAGIC_H_ | 12 #define WEBRTC_BASE_CONSTRUCTORMAGIC_H_ |
13 | 13 |
14 // Undefine macros first, just in case. Some third-party includes have their own | 14 // Undefine macros first, just in case. Some third-party includes have their own |
15 // version. | 15 // version. |
16 | 16 |
17 // Put this in the declarations for a class to be unassignable. | |
17 #undef DISALLOW_ASSIGN | 18 #undef DISALLOW_ASSIGN |
18 #define DISALLOW_ASSIGN(TypeName) \ | 19 #define DISALLOW_ASSIGN(TypeName) \ |
20 void operator=(const TypeName&) = delete | |
tommi
2015/09/07 11:15:27
nit: 4 spaces?
Henrik Grunell WebRTC
2015/09/07 11:56:40
2 spaces in base/macros.h.
| |
21 | |
22 // A macro to disallow the copy constructor and operator= functions | |
23 // This should be used in the private: declarations for a class | |
24 #undef DISALLOW_COPY_AND_ASSIGN | |
25 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | |
Andrew MacDonald
2015/09/07 22:45:36
Any reason not to fix this one as well?
TypeName(
Henrik Grunell WebRTC
2015/09/08 11:41:09
Ah, good catch. It's like this in Chromium because
| |
26 TypeName(const TypeName&); \ | |
19 void operator=(const TypeName&) | 27 void operator=(const TypeName&) |
20 | 28 |
21 // A macro to disallow the evil copy constructor and operator= functions | |
22 // This should be used in the private: declarations for a class. | |
23 #undef DISALLOW_COPY_AND_ASSIGN | |
24 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | |
25 TypeName(const TypeName&); \ | |
26 DISALLOW_ASSIGN(TypeName) | |
27 | |
28 // A macro to disallow all the implicit constructors, namely the | 29 // A macro to disallow all the implicit constructors, namely the |
29 // default constructor, copy constructor and operator= functions. | 30 // default constructor, copy constructor and operator= functions. |
30 // | 31 // |
31 // This should be used in the private: declarations for a class | 32 // This should be used in the private: declarations for a class |
Andrew MacDonald
2015/09/07 22:45:36
Remove "private: ".
Henrik Grunell WebRTC
2015/09/08 11:41:09
Done.
| |
32 // that wants to prevent anyone from instantiating it. This is | 33 // that wants to prevent anyone from instantiating it. This is |
33 // especially useful for classes containing only static methods. | 34 // especially useful for classes containing only static methods. |
34 #undef DISALLOW_IMPLICIT_CONSTRUCTORS | 35 #undef DISALLOW_IMPLICIT_CONSTRUCTORS |
35 #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ | 36 #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ |
36 TypeName(); \ | 37 TypeName() = delete; \ |
37 DISALLOW_COPY_AND_ASSIGN(TypeName) | 38 DISALLOW_COPY_AND_ASSIGN(TypeName) |
38 | 39 |
39 | |
40 #endif // WEBRTC_BASE_CONSTRUCTORMAGIC_H_ | 40 #endif // WEBRTC_BASE_CONSTRUCTORMAGIC_H_ |
OLD | NEW |