Registered Member
|
Hello,
I have these two functions to approximatly compare objects:
https://eigen.tuxfamily.org/dox-devel/c ... xBase.html recommends using MatrixBase like that. However, the other template spezialization is always picked:
I also tried different variants, like the monstrous
which solved some errors, but failed to match math::equals(coords, Eigen::Vector3d::Constant(1.0)) (coords is Eigen::Vector3d)
How should an appropriate template look like? Thanks, Florian |
Moderator
|
I see two approaches. One is to make use of enable_if<> to disable the generic version for non-Eigen types. This will involve some meta-programming kung fu.
The second one is to play with ADL: 1 - Move the generic 'equals(A,B)' to some namespace 'details' and rename it to equals_impl. 2 - Move equals(const MatrixBase<A>&,const MatrixBase<B>&) to namespace Eigen and rename it to equals_impl. 3 - add a new: template<class A, class B> constexpr bool equals(const A a, const B b, const double tolerance = NUMERICAL_ZERO_DIFFERENCE) { using namespace ADL; return equals_impl(a, b, tolerance); } |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]