Blender V5.0
BLI_struct_equality_utils.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
19
20#define BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type) \
21 friend bool operator!=(const Type &a, const Type &b) \
22 { \
23 return !(a == b); \
24 }
25
26#define BLI_STRUCT_EQUALITY_OPERATORS_1(Type, m) \
27 friend bool operator==(const Type &a, const Type &b) \
28 { \
29 return a.m == b.m; \
30 } \
31 BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
32
33#define BLI_STRUCT_EQUALITY_OPERATORS_2(Type, m1, m2) \
34 friend bool operator==(const Type &a, const Type &b) \
35 { \
36 return a.m1 == b.m1 && a.m2 == b.m2; \
37 } \
38 BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
39
40#define BLI_STRUCT_EQUALITY_OPERATORS_3(Type, m1, m2, m3) \
41 friend bool operator==(const Type &a, const Type &b) \
42 { \
43 return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3; \
44 } \
45 BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
46
47#define BLI_STRUCT_EQUALITY_OPERATORS_4(Type, m1, m2, m3, m4) \
48 friend bool operator==(const Type &a, const Type &b) \
49 { \
50 return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3 && a.m4 == b.m4; \
51 } \
52 BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
53
54#define BLI_STRUCT_EQUALITY_OPERATORS_5(Type, m1, m2, m3, m4, m5) \
55 friend bool operator==(const Type &a, const Type &b) \
56 { \
57 return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3 && a.m4 == b.m4 && a.m5 == b.m5; \
58 } \
59 BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
60
61#define BLI_STRUCT_EQUALITY_OPERATORS_6(Type, m1, m2, m3, m4, m5, m6) \
62 friend bool operator==(const Type &a, const Type &b) \
63 { \
64 return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3 && a.m4 == b.m4 && a.m5 == b.m5 && \
65 a.m6 == b.m6; \
66 } \
67 BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)