From 0f42d48cfbbd5a23b38448b57218805d33d9398d Mon Sep 17 00:00:00 2001 From: Janis Born Date: Fri, 10 Feb 2017 15:55:29 +0100 Subject: [PATCH] make Vector11T converting ctor only accept at least 2 arguments (hence making all single-argument ctors explicit) --- src/OpenMesh/Core/Geometry/Vector11T.hh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/OpenMesh/Core/Geometry/Vector11T.hh b/src/OpenMesh/Core/Geometry/Vector11T.hh index de31544c..c9d918ba 100644 --- a/src/OpenMesh/Core/Geometry/Vector11T.hh +++ b/src/OpenMesh/Core/Geometry/Vector11T.hh @@ -112,14 +112,16 @@ class VectorT { //-------------------------------------------------------------- constructors - template::type, + // Converting constructor: Constructs the vector from DIM values (of + // potentially heterogenous types) which are all convertible to Scalar. + template::type, typename = typename std::enable_if< - are_convertible_to::value>::type> - constexpr VectorT(T... vs) : values_ { {static_cast(vs)...} } { - static_assert(sizeof...(T) == DIM, + are_convertible_to::value>::type> + constexpr VectorT(T v, Ts... vs) : values_ { {static_cast(v), static_cast(vs)...} } { + static_assert(sizeof...(Ts)+1 == DIM, "Invalid number of components specified in constructor."); - static_assert(are_convertible_to::value, + static_assert(are_convertible_to::value, "Not all components are convertible to Scalar."); } @@ -367,8 +369,7 @@ class VectorT { auto operator% (const VectorT &_rhs) const -> typename std::enable_if>::type { + (*this)[0] * _rhs[0]), DIM>>::type { return { values_[1] * _rhs[2] - values_[2] * _rhs[1], values_[2] * _rhs[0] - values_[0] * _rhs[2],