henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_BASE_CONSTRUCTORMAGIC_H_ |
| 12 | #define WEBRTC_BASE_CONSTRUCTORMAGIC_H_ |
| 13 | |
henrike@webrtc.org | 680555f | 2014-06-27 15:49:02 +0000 | [diff] [blame] | 14 | // Undefine macros first, just in case. Some third-party includes have their own |
| 15 | // version. |
| 16 | |
| 17 | #undef DISALLOW_ASSIGN |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 18 | #define DISALLOW_ASSIGN(TypeName) \ |
| 19 | void operator=(const TypeName&) |
| 20 | |
| 21 | // A macro to disallow the evil copy constructor and operator= functions |
| 22 | // This should be used in the private: declarations for a class. |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 23 | #undef DISALLOW_COPY_AND_ASSIGN |
| 24 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
| 25 | TypeName(const TypeName&); \ |
| 26 | DISALLOW_ASSIGN(TypeName) |
| 27 | |
| 28 | // Alternative, less-accurate legacy name. |
henrike@webrtc.org | 680555f | 2014-06-27 15:49:02 +0000 | [diff] [blame] | 29 | #undef DISALLOW_EVIL_CONSTRUCTORS |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 30 | #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ |
| 31 | DISALLOW_COPY_AND_ASSIGN(TypeName) |
| 32 | |
| 33 | // A macro to disallow all the implicit constructors, namely the |
| 34 | // default constructor, copy constructor and operator= functions. |
| 35 | // |
| 36 | // This should be used in the private: declarations for a class |
| 37 | // that wants to prevent anyone from instantiating it. This is |
| 38 | // especially useful for classes containing only static methods. |
henrike@webrtc.org | 680555f | 2014-06-27 15:49:02 +0000 | [diff] [blame] | 39 | #undef DISALLOW_IMPLICIT_CONSTRUCTORS |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 40 | #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ |
| 41 | TypeName(); \ |
| 42 | DISALLOW_EVIL_CONSTRUCTORS(TypeName) |
| 43 | |
| 44 | |
| 45 | #endif // WEBRTC_BASE_CONSTRUCTORMAGIC_H_ |