BLI: add utility to check if type is any specific type

This adds `blender::is_same_any_v` which is the almost the same as
`std::is_same_v`. The difference is that it allows for checking multiple
types at the same time.

Differential Revision: https://developer.blender.org/D13673
This commit is contained in:
2021-12-27 16:08:11 +01:00
parent 594438ef0d
commit 51a131ddbc
7 changed files with 24 additions and 16 deletions

View File

@@ -134,12 +134,8 @@ class GeoNodeExecParams {
}
template<typename T>
static inline constexpr bool is_field_base_type_v = std::is_same_v<T, float> ||
std::is_same_v<T, int> ||
std::is_same_v<T, bool> ||
std::is_same_v<T, ColorGeometry4f> ||
std::is_same_v<T, float3> ||
std::is_same_v<T, std::string>;
static inline constexpr bool is_field_base_type_v =
is_same_any_v<T, float, int, bool, ColorGeometry4f, float3, std::string>;
/**
* Get the input value for the input socket with the given identifier.

View File

@@ -180,8 +180,7 @@ static void join_component_type(Span<GeometrySet> src_geometry_sets, GeometrySet
InstancesComponent &instances =
instances_geometry_set.get_component_for_write<InstancesComponent>();
if constexpr (std::is_same_v<Component, InstancesComponent> ||
std::is_same_v<Component, VolumeComponent>) {
if constexpr (is_same_any_v<Component, InstancesComponent, VolumeComponent>) {
join_components(components, result);
}
else {