Cleanup: Use is_same_any_v wrapper

Pull Request: https://projects.blender.org/blender/blender/pulls/132567
This commit is contained in:
Hans Goudey
2025-01-03 19:15:01 +01:00
committed by Hans Goudey
parent 3df7c6a428
commit 48cecef1e0
5 changed files with 7 additions and 14 deletions

View File

@@ -13,6 +13,7 @@
#include "BLI_math_color.h"
#include "BLI_math_vector.h"
#include "BLI_math_vector_types.hh"
#include "BLI_memory_utils.hh"
#include "IMB_imbuf_types.hh"
@@ -49,7 +50,7 @@ struct ImageTileWrapper {
};
template<typename T, int Channels = 4> struct ImageBufferAccessor {
static_assert(std::is_same_v<T, int> || std::is_same_v<T, float4>);
static_assert(is_same_any_v<T, int, float4>);
ImBuf &image_buffer;

View File

@@ -109,8 +109,7 @@ std::unique_ptr<IDProperty, IDPropertyDeleter> create_array(StringRef prop_name,
Span<PrimitiveType> values,
const eIDPropertyFlag flags)
{
static_assert(std::is_same_v<PrimitiveType, int32_t> || std::is_same_v<PrimitiveType, float> ||
std::is_same_v<PrimitiveType, double>,
static_assert(is_same_any_v<PrimitiveType, int32_t, float, double>,
"Allowed values for PrimitiveType are int32_t, float and double.");
static_assert(!std::is_same_v<PrimitiveType, int32_t> || id_property_subtype == IDP_INT,
"PrimitiveType and id_property_type do not match (int32_t).");

View File

@@ -987,8 +987,7 @@ template<typename T> constexpr int Result::get_type_channels_count()
template<typename T> constexpr bool Result::is_supported_type()
{
return std::is_same_v<T, float> || std::is_same_v<T, float2> || std::is_same_v<T, float3> ||
std::is_same_v<T, float4> || std::is_same_v<T, int2>;
return is_same_any_v<T, float, float2, float3, float4, int2>;
}
template<typename T> inline int64_t Result::get_pixel_index(const int2 &texel) const

View File

@@ -126,9 +126,7 @@ void curve_simplify(const Span<float3> positions,
{
bke::attribute_math::convert_to_static_type(attribute_data.type(), [&](auto dummy) {
using T = decltype(dummy);
if constexpr (std::is_same_v<T, float> || std::is_same_v<T, float2> ||
std::is_same_v<T, float3>)
{
if constexpr (is_same_any_v<T, float, float2, float3>) {
curve_simplify(positions, cyclic, epsilon, attribute_data.typed<T>(), points_to_delete);
}
});
@@ -152,9 +150,7 @@ IndexMask simplify_curve_attribute(const Span<float3> positions,
const IndexRange points = points_by_curve[curve_i];
bke::attribute_math::convert_to_static_type(attribute_data.type(), [&](auto dummy) {
using T = decltype(dummy);
if constexpr (std::is_same_v<T, float> || std::is_same_v<T, float2> ||
std::is_same_v<T, float3>)
{
if constexpr (is_same_any_v<T, float, float2, float3>) {
curve_simplify(positions.slice(points),
cyclic[curve_i],
epsilon,

View File

@@ -159,9 +159,7 @@ void gaussian_blur_1D(const GSpan src,
using T = decltype(dummy);
/* Only allow smoothing of float, float2, or float3. */
/* Reduces unnecessary code generation. */
if constexpr (std::is_same_v<T, float> || std::is_same_v<T, float2> ||
std::is_same_v<T, float3>)
{
if constexpr (is_same_any_v<T, float, float2, float3>) {
gaussian_blur_1D(src.typed<T>(),
iterations,
influence_by_point,