-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcm_ctors.h
40 lines (34 loc) · 2.16 KB
/
cm_ctors.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
// helper macros to declare/delete copy-moves
// test must be used OUTSIDE class definition like
/*
class A{};
TEST_MOVE_NOEX(A);
*/
// NOLINTNEXTLINE
#define TEST_MOVE_NOEX(TYPE) \
static_assert(std::is_nothrow_move_constructible_v<TYPE> \
&& std::is_nothrow_move_assignable_v<TYPE>, \
" Should be noexcept Moves.")
// NOLINTNEXTLINE
#define NO_COPYMOVE(TYPE) \
TYPE(const TYPE &) = delete; \
TYPE(TYPE &&) = delete; \
TYPE &operator=(const TYPE &) = delete; \
TYPE &operator=(TYPE &&) = delete
// NOLINTNEXTLINE
#define DEFAULT_COPYMOVE(TYPE) \
TYPE(const TYPE &) = default; \
TYPE(TYPE &&) = default; \
TYPE &operator=(const TYPE &) = default; \
TYPE &operator=(TYPE &&) = default // NOLINT
// NOLINTNEXTLINE
#define MOVEONLY_ALLOWED(TYPE) \
TYPE(const TYPE &) = delete; \
TYPE(TYPE &&) = default; \
TYPE &operator=(const TYPE &) = delete; \
TYPE &operator=(TYPE &&) = default // NOLINT
// only stack allocation allowed
#define STACK_ONLY \
static void *operator new(size_t) = delete; \
static void *operator new[](size_t) = delete