Commit dda4b41c authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

C++11: Got rid of narrowing conversion warnings in legacy code.

Added explicit static_cast along with static SFINAE checks to VectorT
constructor.
parent 26914cba
......@@ -92,6 +92,23 @@ namespace OpenMesh {
//== CLASS DEFINITION =========================================================
#if CPP11_ENABLED
/*
* Helpers for VectorT
*/
namespace {
template<typename... Ts>
struct are_convertible_to;
template<typename To, typename From, typename... Froms>
struct are_convertible_to<To, From, Froms...> {
static constexpr bool value = std::is_convertible<From, To>::value && are_convertible_to<To, Froms...>::value;
};
template<typename To, typename From>
struct are_convertible_to<To, From> : public std::is_convertible<From, To> {};
}
#endif
/** The N values of the template Scalar type are the only data members
of the class VectorT<Scalar,N>. This guarantees 100% compatibility
......
......@@ -102,8 +102,10 @@ public:
vectorize(v);
}
template<typename... T, typename = typename std::enable_if<sizeof...(T) == DIM>::type>
constexpr VectorT(T... vs) : Base {vs...}
template<typename... T,
typename = typename std::enable_if<sizeof...(T) == DIM>::type,
typename = typename std::enable_if<are_convertible_to<float, T...>::value>::type>
constexpr VectorT(T... vs) : Base { static_cast<Scalar>(vs)...}
{ }
#else
/// special constructor for 1D vectors
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment