From 687da4e08f339f735b56f71c3ba32b831ba18059 Mon Sep 17 00:00:00 2001 From: Hans-Christian Ebke Date: Thu, 19 Nov 2015 11:10:28 +0100 Subject: [PATCH] C++11: Added static_asserts to component-wise constructor. --- src/OpenMesh/Core/Geometry/Vector11T.hh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/Geometry/Vector11T.hh b/src/OpenMesh/Core/Geometry/Vector11T.hh index bdc9db25..1a5fcf23 100644 --- a/src/OpenMesh/Core/Geometry/Vector11T.hh +++ b/src/OpenMesh/Core/Geometry/Vector11T.hh @@ -122,8 +122,12 @@ class VectorT { typename = typename std::enable_if::type, typename = typename std::enable_if< are_convertible_to::value>::type> - constexpr VectorT(T... vs) : values_ { {static_cast(vs)...} } - {} + constexpr VectorT(T... vs) : values_ { {static_cast(vs)...} } { + static_assert(sizeof...(T) == DIM, + "Invalid number of components specified in constructor."); + static_assert(are_convertible_to::value, + "Not all components are convertible to Scalar."); + } VectorT(const VectorT &rhs) = default; VectorT(VectorT &&rhs) = default;