BLI: fix constructor regression for Vector and Array
This was introduced in rB403384998a6bb5f428e15ced5.
This commit is contained in:
parent
644a915b1b
commit
a19584a471
|
@ -105,6 +105,10 @@ class Array {
|
|||
{
|
||||
}
|
||||
|
||||
Array(const std::initializer_list<T> &values) : Array(Span<T>(values))
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new array with the given size. All values will be default constructed. For trivial
|
||||
* types like int, default construction does nothing.
|
||||
|
|
|
@ -167,6 +167,10 @@ class Vector {
|
|||
{
|
||||
}
|
||||
|
||||
Vector(const std::initializer_list<T> &values) : Vector(Span<T>(values))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename U,
|
||||
size_t N,
|
||||
typename std::enable_if_t<std::is_convertible_v<U, T>> * = nullptr>
|
||||
|
|
|
@ -285,4 +285,14 @@ TEST(span, CastLargerSize)
|
|||
EXPECT_EQ(new_a_span.size(), 2u);
|
||||
}
|
||||
|
||||
TEST(span, VoidPointerSpan)
|
||||
{
|
||||
int a;
|
||||
float b;
|
||||
double c;
|
||||
|
||||
auto func1 = [](Span<void *> span) { EXPECT_EQ(span.size(), 3); };
|
||||
func1({&a, &b, &c});
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
@ -651,4 +651,13 @@ TEST(vector, OveralignedValues)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(vector, ConstructVoidPointerVector)
|
||||
{
|
||||
int a;
|
||||
float b;
|
||||
double c;
|
||||
Vector<void *> vec = {&a, &b, &c};
|
||||
EXPECT_EQ(vec.size(), 3);
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
@ -65,8 +65,7 @@ TEST(mutable_attributes_ref, ComplexTest)
|
|||
Array<float> sizes(amount);
|
||||
Array<std::string> names(amount);
|
||||
|
||||
Array<void *> buffers = {
|
||||
(void *)positions.data(), (void *)ids.data(), (void *)sizes.data(), (void *)names.data()};
|
||||
Array<void *> buffers = {positions.data(), ids.data(), sizes.data(), names.data()};
|
||||
MutableAttributesRef attributes{info, buffers, IndexRange(1, 3)};
|
||||
EXPECT_EQ(attributes.size(), 3);
|
||||
EXPECT_EQ(attributes.info().size(), 4);
|
||||
|
|
|
@ -369,7 +369,7 @@ TEST(multi_function, CustomMF_Convert)
|
|||
CustomMF_Convert<float, int> fn;
|
||||
|
||||
Array<float> inputs = {5.4f, 7.1f, 9.0f};
|
||||
Array<int> outputs{inputs.size(), 0};
|
||||
Array<int> outputs(inputs.size(), 0);
|
||||
|
||||
MFParamsBuilder params(fn, inputs.size());
|
||||
params.add_readonly_single_input(inputs.as_span());
|
||||
|
|
Loading…
Reference in New Issue