1 //
2 // Copyright (c) 2021 Travis Geiselbrecht
3 //
4 // Use of this source code is governed by a MIT-style
5 // license that can be found in the LICENSE file or at
6 // https://opensource.org/licenses/MIT
7 //
8 // Copyright 2016 The Fuchsia Authors. All rights reserved.
9 // Use of this source code is governed by a BSD-style license that can be
10 // found in the LICENSE file.
11 #pragma once
12 
13 // Helper routines used in C++ code in LK
14 
15 // Macro used to simplify the task of deleting all of the default copy
16 // constructors and assignment operators.
17 #define DISALLOW_COPY_ASSIGN_AND_MOVE(_class_name)       \
18     _class_name(const _class_name&) = delete;            \
19     _class_name(_class_name&&) = delete;                 \
20     _class_name& operator=(const _class_name&) = delete; \
21     _class_name& operator=(_class_name&&) = delete
22 
23 // Macro used to simplify the task of deleting the non rvalue reference copy
24 // constructors and assignment operators.  (IOW - forcing move semantics)
25 #define DISALLOW_COPY_AND_ASSIGN_ALLOW_MOVE(_class_name) \
26     _class_name(const _class_name&) = delete;            \
27     _class_name& operator=(const _class_name&) = delete
28 
29 // Macro used to simplify the task of deleting the new and new[]
30 // operators. (IOW - disallow heap allocations)
31 #define DISALLOW_NEW                       \
32     static void* operator new(size_t) = delete;   \
33     static void* operator new[](size_t) = delete
34 
35