Commit 61fe9dab authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

C++11: Making sure VectorT construction from iterator is only instantiated for actual iterators.

parent cdfd266c
Pipeline #51 passed with stage
......@@ -158,8 +158,11 @@ class VectorT {
}
/// construct from a value array or any other iterator
template<typename Iterator>
explicit inline VectorT(Iterator it) {
template<typename Iterator,
typename = decltype(
*std::declval<Iterator&>(), void(),
++std::declval<Iterator&>(), void())>
explicit VectorT(Iterator it) {
std::copy_n(it, DIM, values_.begin());
}
......@@ -167,7 +170,7 @@ class VectorT {
template<typename otherScalarType,
typename = typename std::enable_if<
std::is_convertible<otherScalarType, Scalar>::value>>
explicit inline VectorT(const VectorT<otherScalarType, DIM>& _rhs) {
explicit VectorT(const VectorT<otherScalarType, DIM>& _rhs) {
operator=(_rhs);
}
......@@ -376,7 +379,7 @@ class VectorT {
/// \see OpenMesh::dot
template<typename OtherScalar>
auto operator|(const VectorT<OtherScalar, DIM>& _rhs) const ->
decltype(*data() * *_rhs.data()) {
decltype(*this->data() * *_rhs.data()) {
return std::inner_product(data() + 1, data() + DIM, _rhs.data() + 1,
*data() * *_rhs.data());
......
......@@ -214,6 +214,9 @@ TEST_F(OpenMeshVectorTest, array_init) {
float a[3]; a[0] = 1.0; a[1] = 2.0; a[2] = 3.0;
OpenMesh::Vec3f v(a);
EXPECT_EQ(OpenMesh::Vec3f(1.0, 2.0, 3.0), v);
// This should not invoke the array constructor.
OpenMesh::Vec3d v2(3.0f);
}
TEST_F(OpenMeshVectorTest, normalized_cond) {
......
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