Home | History | Annotate | Download | only in base
      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 
     14 #define DISALLOW_ASSIGN(TypeName) \
     15   void operator=(const TypeName&)
     16 
     17 // A macro to disallow the evil copy constructor and operator= functions
     18 // This should be used in the private: declarations for a class.
     19 // Undefine this, just in case. Some third-party includes have their own
     20 // version.
     21 #undef DISALLOW_COPY_AND_ASSIGN
     22 #define DISALLOW_COPY_AND_ASSIGN(TypeName)    \
     23   TypeName(const TypeName&);                    \
     24   DISALLOW_ASSIGN(TypeName)
     25 
     26 // Alternative, less-accurate legacy name.
     27 #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) \
     28   DISALLOW_COPY_AND_ASSIGN(TypeName)
     29 
     30 // A macro to disallow all the implicit constructors, namely the
     31 // default constructor, copy constructor and operator= functions.
     32 //
     33 // This should be used in the private: declarations for a class
     34 // that wants to prevent anyone from instantiating it. This is
     35 // especially useful for classes containing only static methods.
     36 #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
     37   TypeName();                                    \
     38   DISALLOW_EVIL_CONSTRUCTORS(TypeName)
     39 
     40 
     41 #endif  // WEBRTC_BASE_CONSTRUCTORMAGIC_H_
     42