Blender V4.3
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
5#pragma once
6
16#define BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type) \
17 friend bool operator!=(const Type &a, const Type &b) \
18 { \
19 return !(a == b); \
20 }
21
22#define BLI_STRUCT_EQUALITY_OPERATORS_1(Type, m) \
23 friend bool operator==(const Type &a, const Type &b) \
24 { \
25 return a.m == b.m; \
26 } \
27 BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
28
29#define BLI_STRUCT_EQUALITY_OPERATORS_2(Type, m1, m2) \
30 friend bool operator==(const Type &a, const Type &b) \
31 { \
32 return a.m1 == b.m1 && a.m2 == b.m2; \
33 } \
34 BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
35
36#define BLI_STRUCT_EQUALITY_OPERATORS_3(Type, m1, m2, m3) \
37 friend bool operator==(const Type &a, const Type &b) \
38 { \
39 return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3; \
40 } \
41 BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
42
43#define BLI_STRUCT_EQUALITY_OPERATORS_4(Type, m1, m2, m3, m4) \
44 friend bool operator==(const Type &a, const Type &b) \
45 { \
46 return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3 && a.m4 == b.m4; \
47 } \
48 BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
49
50#define BLI_STRUCT_EQUALITY_OPERATORS_5(Type, m1, m2, m3, m4, m5) \
51 friend bool operator==(const Type &a, const Type &b) \
52 { \
53 return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3 && a.m4 == b.m4 && a.m5 == b.m5; \
54 } \
55 BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)