c++ - Operator overloading and iterator confusion -


i use code find point of box (g) furthest in direction d typedef vector_t point_t;

std::vector<point_t> corners = g.getallcorners(); coordinate_type last_val = 0;  std::vector<point_t>::const_iterator = corners.begin(); point_t last_max = *it;  {     coordinate_type new_val = dot_product( *it, d );     if( new_val > last_val )     {         last_val = new_val;         last_max = *it;     } } while( != corners.end() );  return last_max; 

i have template operator overload operator != class vector_t in namespace point.

namespace point {     template      <         typename lhs_vector3d_impl,          typename rhs_vector3d_impl     >     bool operator!=( const typename lhs_vector3d_impl& lhs, const typename rhs_vector3d_impl& rhs )     {         return binary_operator_not_equal<lhs_vector3d_impl, rhs_vector3d_impl>::apply( lhs, rhs );     } }; 

the overload works fine in cases when use iterators (i.e. it != corners.end()) breaks down since did not intend function in case. can tell it's because of template parameters resolution going wrong don't know why:

lhs_vector3d_impl=std::_vector_const_iterator<std::_vector_val<std::_simple_types<legend::geometry::point::carray_vector3d<int32_t>>>>, rhs_vector3d_impl=std::_vector_iterator<std::_vector_val<std::_simple_types<legend::geometry::point::carray_vector3d<int32_t>>>> 

i understand wrong functions called don’t understand why…

so question how comme iterator comparaison gets resolved function instead of operator in std namespace , how can prevent function being used.

note 1: beginning template may doing wrong without knowing, if please kindly tell.

note 2: code used academic purposes want of hand.

note 3: using visual studio 2012 c++ compiler

i don't see why yu need template function. may have deduced lhs , rhs type iterator when wanted use point_t

two solutions :

  1. remove templates on operator definition , use point_t type (so sure)
  2. remove using namespace sure sees iterator outside of namespace point

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -