C++11: Making sure VectorT construction from iterator is only instantiated for actual iterators.
This commit is contained in:
@@ -158,8 +158,11 @@ class VectorT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// construct from a value array or any other iterator
|
/// construct from a value array or any other iterator
|
||||||
template<typename Iterator>
|
template<typename Iterator,
|
||||||
explicit inline VectorT(Iterator it) {
|
typename = decltype(
|
||||||
|
*std::declval<Iterator&>(), void(),
|
||||||
|
++std::declval<Iterator&>(), void())>
|
||||||
|
explicit VectorT(Iterator it) {
|
||||||
std::copy_n(it, DIM, values_.begin());
|
std::copy_n(it, DIM, values_.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +170,7 @@ class VectorT {
|
|||||||
template<typename otherScalarType,
|
template<typename otherScalarType,
|
||||||
typename = typename std::enable_if<
|
typename = typename std::enable_if<
|
||||||
std::is_convertible<otherScalarType, Scalar>::value>>
|
std::is_convertible<otherScalarType, Scalar>::value>>
|
||||||
explicit inline VectorT(const VectorT<otherScalarType, DIM>& _rhs) {
|
explicit VectorT(const VectorT<otherScalarType, DIM>& _rhs) {
|
||||||
operator=(_rhs);
|
operator=(_rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +379,7 @@ class VectorT {
|
|||||||
/// \see OpenMesh::dot
|
/// \see OpenMesh::dot
|
||||||
template<typename OtherScalar>
|
template<typename OtherScalar>
|
||||||
auto operator|(const VectorT<OtherScalar, DIM>& _rhs) const ->
|
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,
|
return std::inner_product(data() + 1, data() + DIM, _rhs.data() + 1,
|
||||||
*data() * *_rhs.data());
|
*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;
|
float a[3]; a[0] = 1.0; a[1] = 2.0; a[2] = 3.0;
|
||||||
OpenMesh::Vec3f v(a);
|
OpenMesh::Vec3f v(a);
|
||||||
EXPECT_EQ(OpenMesh::Vec3f(1.0, 2.0, 3.0), v);
|
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) {
|
TEST_F(OpenMeshVectorTest, normalized_cond) {
|
||||||
|
|||||||
Reference in New Issue
Block a user