From dda4b41cac6264d7ddd7ee1004c5edce919a3ec0 Mon Sep 17 00:00:00 2001 From: Hans-Christian Ebke Date: Mon, 9 Nov 2015 22:55:42 +0100 Subject: [PATCH] C++11: Got rid of narrowing conversion warnings in legacy code. Added explicit static_cast along with static SFINAE checks to VectorT constructor. --- src/OpenMesh/Core/Geometry/VectorT.hh | 17 +++++++++++++++++ src/OpenMesh/Core/Geometry/VectorT_inc.hh | 6 ++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/Geometry/VectorT.hh b/src/OpenMesh/Core/Geometry/VectorT.hh index 38a463e8..7be16f0e 100644 --- a/src/OpenMesh/Core/Geometry/VectorT.hh +++ b/src/OpenMesh/Core/Geometry/VectorT.hh @@ -92,6 +92,23 @@ namespace OpenMesh { //== CLASS DEFINITION ========================================================= +#if CPP11_ENABLED +/* + * Helpers for VectorT + */ +namespace { +template +struct are_convertible_to; + +template +struct are_convertible_to { + static constexpr bool value = std::is_convertible::value && are_convertible_to::value; +}; +template +struct are_convertible_to : public std::is_convertible {}; +} +#endif + /** The N values of the template Scalar type are the only data members of the class VectorT. This guarantees 100% compatibility diff --git a/src/OpenMesh/Core/Geometry/VectorT_inc.hh b/src/OpenMesh/Core/Geometry/VectorT_inc.hh index 6fd4d3c3..3f045a19 100644 --- a/src/OpenMesh/Core/Geometry/VectorT_inc.hh +++ b/src/OpenMesh/Core/Geometry/VectorT_inc.hh @@ -102,8 +102,10 @@ public: vectorize(v); } - template::type> - constexpr VectorT(T... vs) : Base {vs...} + template::type, + typename = typename std::enable_if::value>::type> + constexpr VectorT(T... vs) : Base { static_cast(vs)...} { } #else /// special constructor for 1D vectors