diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index ba53288cc..66ade42a7 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -29,6 +29,7 @@ class VectorTest: public Corrade::TestSuite::Tester { void constructFromData(); void constructDefault(); void constructOneValue(); + void constructOneComponent(); void constructConversion(); void data(); @@ -68,6 +69,7 @@ VectorTest::VectorTest() { addTests(&VectorTest::constructFromData, &VectorTest::constructDefault, &VectorTest::constructOneValue, + &VectorTest::constructOneComponent, &VectorTest::constructConversion, &VectorTest::data, @@ -109,9 +111,15 @@ void VectorTest::constructDefault() { } void VectorTest::constructOneValue() { - CORRADE_EXPECT_FAIL("Constructing Vector from one value is broken."); - CORRADE_VERIFY(false); -// CORRADE_COMPARE(Vector4(7.25f), Vector4(7.25f, 7.25f, 7.25f, 7.25f)); + CORRADE_COMPARE(Vector4(7.25f), Vector4(7.25f, 7.25f, 7.25f, 7.25f)); +} + +void VectorTest::constructOneComponent() { + typedef Vector<1, float> Vector1; + + /* Implicit constructor must work */ + Vector1 vec = 1; + CORRADE_COMPARE(vec, Vector1(1)); } void VectorTest::constructConversion() { diff --git a/src/Math/Vector.h b/src/Math/Vector.h index f05b2ff6f..97568a4cf 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -135,18 +135,17 @@ template class Vector { * @param first First value * @param next Next values */ - template inline constexpr /*implicit*/ Vector(T first, U... next): _data{first, next...} { - static_assert(sizeof...(next)+1 == size, "Improper number of arguments passed to Vector constructor"); - } + #ifdef DOXYGEN_GENERATING_OUTPUT + template inline constexpr /*implicit*/ Vector(T first, U... next); + #else + template::type> inline constexpr /*implicit*/ Vector(T first, U... next): _data{first, next...} {} + #endif - /** - * @brief Construct vector with one value for all fields - * @todo Fix this to be actually usable (not only in subclasses) - */ + /** @brief Construct vector with one value for all fields */ #ifdef DOXYGEN_GENERATING_OUTPUT - inline explicit Vector(T value) { + inline explicit Vector(T value); #else - template inline explicit Vector(typename std::enable_if::value && size != 1, U>::type value) { + template::value && size != 1, T>::type> inline explicit Vector(U value) { #endif for(std::size_t i = 0; i != size; ++i) _data[i] = value;