Skip to content

Commit

Permalink
Implement DISALLOW_COPY_AND_ASSIGN using =delete for Linux only.
Browse files Browse the repository at this point in the history
This lands the new implementation for only (non-CrOS) Linux.  Hopefully this
will prevent regressions in cross-platform code while other platforms are
brought up.

BUG=447156
TEST=none

Review-Url: https://codereview.chromium.org/2006733006
Cr-Commit-Position: refs/heads/master@{#396295}
  • Loading branch information
pkasting authored and Commit bot committed May 26, 2016
1 parent 793dac0 commit 999f15f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions base/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <stddef.h> // For size_t.

#include "build/build_config.h" // For OS_XXX. TODO(pkasting): Remove.

// Put this in the declarations for a class to be uncopyable.
#define DISALLOW_COPY(TypeName) \
TypeName(const TypeName&) = delete
Expand All @@ -20,11 +22,20 @@
#define DISALLOW_ASSIGN(TypeName) \
void operator=(const TypeName&) = delete

// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
// A macro to disallow the copy constructor and operator= functions.
// This should be used in the private: declarations for a class.
// TODO(pkasting): Using "= delete" is Linux-specific initially to prevent
// cross-platform code from regressing while other platforms are fixed. Remove
// the ifdefs here and use "= delete" on all platforms.
#if defined(CHROMIUM_BUILD) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete
#else
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
#endif

// A macro to disallow all the implicit constructors, namely the
// default constructor, copy constructor and operator= functions.
Expand Down

0 comments on commit 999f15f

Please sign in to comment.