Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions src/butil/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
// There must be many copy-paste versions of these macros which are same
// things, undefine them to avoid conflict.
#undef DISALLOW_COPY
#undef DISALLOW_MOVE
#undef DISALLOW_ASSIGN
#undef DISALLOW_MOVE_ASSIGN
#undef DISALLOW_COPY_AND_ASSIGN
#undef DISALLOW_COPY_AND_MOVE
#undef DISALLOW_EVIL_CONSTRUCTORS
#undef DISALLOW_IMPLICIT_CONSTRUCTORS

Expand All @@ -31,20 +34,38 @@
#define BUTIL_DELETE_FUNCTION(decl) decl = delete
#endif

// Put this in the private: declarations for a class to be uncopyable.
// Declarations for a class to be uncopyable.
#define DISALLOW_COPY(TypeName) \
BUTIL_DELETE_FUNCTION(TypeName(const TypeName&))

// Put this in the private: declarations for a class to be unassignable.
#define DISALLOW_ASSIGN(TypeName) \
BUTIL_DELETE_FUNCTION(void operator=(const TypeName&))
// Declarations for a class to be unmovable.
#define DISALLOW_MOVE(TypeName) \
BUTIL_DELETE_FUNCTION(TypeName(TypeName&&))

// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
BUTIL_DELETE_FUNCTION(TypeName(const TypeName&)); \
// Declarations for a class to be unassignable.
#define DISALLOW_ASSIGN(TypeName) \
BUTIL_DELETE_FUNCTION(void operator=(const TypeName&))

// Declarations for a class to be move-unassignable.
#define DISALLOW_MOVE_ASSIGN(TypeName) \
BUTIL_DELETE_FUNCTION(void operator=(TypeName&&))

// A macro to disallow the copy constructor and operator= functions.
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
DISALLOW_COPY(TypeName); \
DISALLOW_ASSIGN(TypeName)

// A macro to disallow the move constructor and operator= functions.
#define DISALLOW_MOVE_AND_ASSIGN(TypeName) \
DISALLOW_MOVE(TypeName); \
DISALLOW_MOVE_ASSIGN(TypeName)

// A macro to disallow the copy constructor,
// the move constructor and operator= functions.
#define DISALLOW_COPY_AND_MOVE(TypeName) \
DISALLOW_COPY_AND_ASSIGN(TypeName); \
DISALLOW_MOVE(TypeName)

// An older, deprecated, politically incorrect name for the above.
// NOTE: The usage of this macro was banned from our code base, but some
// third_party libraries are yet using it.
Expand Down
Loading