blob: ddfd9927d0352249201a26ebcf97641b3bb2e744 [file] [log] [blame]
Lingfeng Yangd7447042018-10-25 11:09:18 -07001// Copyright 2014 The Android Open Source Project
2//
3// This software is licensed under the terms of the GNU General Public
4// License version 2, as published by the Free Software Foundation, and
5// may be copied, distributed, and modified under those terms.
6//
7// This program is distributed in the hope that it will be useful,
8// but WITHOUT ANY WARRANTY; without even the implied warranty of
9// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10// GNU General Public License for more details.
11
12#pragma once
13
14// Use this inside a class declaration to ensure that the corresponding objects
15// cannot be copy-constructed or assigned. For example:
16//
17// class Foo {
18// ....
19// DISALLOW_COPY_AND_ASSIGN(Foo)
20// ....
21// };
22//
23// Note: this macro is sometimes defined in 3rd-party libs, so let's check first
24#ifndef DISALLOW_COPY_AND_ASSIGN
25
26#define DISALLOW_COPY_AND_ASSIGN(T) \
27 T(const T& other) = delete; \
28 T& operator=(const T& other) = delete
29
30#endif
31
32#ifndef DISALLOW_COPY_ASSIGN_AND_MOVE
33
34#define DISALLOW_COPY_ASSIGN_AND_MOVE(T) \
35 DISALLOW_COPY_AND_ASSIGN(T); \
36 T(T&&) = delete; \
37 T& operator=(T&&) = delete
38
39#endif