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 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame^] | 14 | #define RTC_DISALLOW_ASSIGN(TypeName) \ |
tommi | 9a78d22 | 2015-09-10 01:41:55 -0700 | [diff] [blame] | 15 | void operator=(const TypeName&) |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 16 | |
tommi | 9a78d22 | 2015-09-10 01:41:55 -0700 | [diff] [blame] | 17 | // A macro to disallow the evil copy constructor and operator= functions |
| 18 | // This should be used in the private: declarations for a class. |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame^] | 19 | #define RTC_DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
| 20 | TypeName(const TypeName&); \ |
| 21 | RTC_DISALLOW_ASSIGN(TypeName) |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 22 | |
tommi | 9a78d22 | 2015-09-10 01:41:55 -0700 | [diff] [blame] | 23 | // A macro to disallow all the implicit constructors, namely the |
| 24 | // default constructor, copy constructor and operator= functions. |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 25 | // |
tommi | 9a78d22 | 2015-09-10 01:41:55 -0700 | [diff] [blame] | 26 | // This should be used in the private: declarations for a class |
| 27 | // that wants to prevent anyone from instantiating it. This is |
| 28 | // especially useful for classes containing only static methods. |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame^] | 29 | #define RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ |
| 30 | TypeName(); \ |
| 31 | RTC_DISALLOW_COPY_AND_ASSIGN(TypeName) |
tommi | 9a78d22 | 2015-09-10 01:41:55 -0700 | [diff] [blame] | 32 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 33 | #endif // WEBRTC_BASE_CONSTRUCTORMAGIC_H_ |