Blender V4.3
BLI_struct_equality_utils.hh File Reference

Go to the source code of this file.

Macros

#define BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
 
#define BLI_STRUCT_EQUALITY_OPERATORS_1(Type, m)
 
#define BLI_STRUCT_EQUALITY_OPERATORS_2(Type, m1, m2)
 
#define BLI_STRUCT_EQUALITY_OPERATORS_3(Type, m1, m2, m3)
 
#define BLI_STRUCT_EQUALITY_OPERATORS_4(Type, m1, m2, m3, m4)
 
#define BLI_STRUCT_EQUALITY_OPERATORS_5(Type, m1, m2, m3, m4, m5)
 

Macro Definition Documentation

◆ BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR

#define BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR ( Type)
Value:
friend bool operator!=(const Type &a, const Type &b) \
{ \
return !(a == b); \
}
local_group_size(16, 16) .push_constant(Type b
ccl_device_inline bool operator!=(const float2 a, const float2 b)

The macros below reduce the boilerplate needed to implement basic equality operators for structs. These macros could be removed starting with C++20, because then we can use defaulted comparison operators: https://en.cppreference.com/w/cpp/language/default_comparisons

Using these macros also reduces the probably for common typos, like comparing a value to itself or comparing the same value twice.

Definition at line 16 of file BLI_struct_equality_utils.hh.

◆ BLI_STRUCT_EQUALITY_OPERATORS_1

#define BLI_STRUCT_EQUALITY_OPERATORS_1 ( Type,
m )
Value:
friend bool operator==(const Type &a, const Type &b) \
{ \
return a.m == b.m; \
} \
BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)
bool operator==(const AssetWeakReference &a, const AssetWeakReference &b)

Definition at line 22 of file BLI_struct_equality_utils.hh.

◆ BLI_STRUCT_EQUALITY_OPERATORS_2

#define BLI_STRUCT_EQUALITY_OPERATORS_2 ( Type,
m1,
m2 )
Value:
friend bool operator==(const Type &a, const Type &b) \
{ \
return a.m1 == b.m1 && a.m2 == b.m2; \
} \
BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)

Definition at line 29 of file BLI_struct_equality_utils.hh.

Referenced by blender::nodes::ENUM_OPERATORS().

◆ BLI_STRUCT_EQUALITY_OPERATORS_3

#define BLI_STRUCT_EQUALITY_OPERATORS_3 ( Type,
m1,
m2,
m3 )
Value:
friend bool operator==(const Type &a, const Type &b) \
{ \
return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3; \
} \
BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)

Definition at line 36 of file BLI_struct_equality_utils.hh.

◆ BLI_STRUCT_EQUALITY_OPERATORS_4

#define BLI_STRUCT_EQUALITY_OPERATORS_4 ( Type,
m1,
m2,
m3,
m4 )
Value:
friend bool operator==(const Type &a, const Type &b) \
{ \
return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3 && a.m4 == b.m4; \
} \
BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)

Definition at line 43 of file BLI_struct_equality_utils.hh.

◆ BLI_STRUCT_EQUALITY_OPERATORS_5

#define BLI_STRUCT_EQUALITY_OPERATORS_5 ( Type,
m1,
m2,
m3,
m4,
m5 )
Value:
friend bool operator==(const Type &a, const Type &b) \
{ \
return a.m1 == b.m1 && a.m2 == b.m2 && a.m3 == b.m3 && a.m4 == b.m4 && a.m5 == b.m5; \
} \
BLI_STRUCT_DERIVED_UNEQUAL_OPERATOR(Type)

Definition at line 50 of file BLI_struct_equality_utils.hh.