c++ - How sort unique on a std::vector of Eigen::Vector? -


the compiler can't figure out less operator type. i've tried lambda , predicate function.

#include <eigen/dense> typedef eigen::vector3f vec3;  inline bool operator<(const vec3 &lhs, const vec3 &rhs) {     return lhs.x() < rhs.x() && lhs.y() < rhs.y() && lhs.z() < rhs.z(); }  inline bool cmpvecs(const vec3 &lhs, const vec3 &rhs) {     return lhs.x() < rhs.x() && lhs.y() < rhs.y() && lhs.z() < rhs.z(); }   inline void removeduplicates(std::vector<vec3> &con) {     std::sort(con.data(), con.data() + con.size());     auto itr = std::unique(con.begin(), con.end(), cmpvecs);     con.resize(itr - con.begin()); }  void init(std::vector<vec3> &verts) {     removeduplicates(verts); } 

vs 2012 error:

algorithm(3618): error c2678: binary '<' : no operator found takes left-hand operand of type 'eigen::matrix<_scalar,_rows,_cols>' (or there no acceptable conversion) 1> 1> [ 1> _scalar=float, 1> _rows=3, 1>
_cols=1 1> ]

related posts:

std::sort has override available allows specify comparator want use, example:

struct vec3comp{     bool operator()(const vec3 &lhs, const vec3 &rhs){         return lhs.x() < rhs.x() && lhs.y() < rhs.y() && lhs.z() < rhs.z();     } } mycomp;  std::sort(con.data(), con.data() + con.size(),mycomp);` 

edit: can show code lambda function? should work fine.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -