Commit e8b56394 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Deprecate DISALLOW_xxx and add Dos-And-Don'ts guidance around it.


Bug: 1010217
Change-Id: Iaa1d73bfec3522db08d04bedeb59603e16c8ffe0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895857
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711900}
parent 822d6aef
......@@ -10,6 +10,10 @@
#ifndef BASE_MACROS_H_
#define BASE_MACROS_H_
// ALL DISALLOW_xxx MACROS ARE DEPRECATED; DO NOT USE IN NEW CODE.
// Use explicit deletions instead. See the section on copyability/movability in
// //styleguide/c++/c++-dos-and-donts.md for more information.
// Put this in the declarations for a class to be uncopyable.
#define DISALLOW_COPY(TypeName) \
TypeName(const TypeName&) = delete
......
......@@ -37,6 +37,23 @@ void foo() {
}
```
## Explicitly declare class copyability/movability
The
[Google Style Guide](http://google.github.io/styleguide/cppguide.html#Copyable_Movable_Types)
says classes can omit copy/move declarations or deletions "only if they are
obvious". Because "obvious" is subjective and even the examples in the style
guide take some thought to figure out, being explicit is clear, simple, and
avoids any risk of accidental copying.
Declare or delete these operations in the public section, between other
constructors and the destructor; `DISALLOW_COPY_AND_ASSIGN` is deprecated. For
a non-copyable/movable type, delete the copy operations (the move operations
will be implicitly deleted); otherwise, declare either copy operations, move
operations, or both (a non-declared pair will be implicitly deleted). Always
declare or delete both construction and assignment, not just one (which can
introduce subtle bugs).
## Variable initialization
There are myriad ways to initialize variables in C++11. Prefer the following
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment