Original Post
Hi all, I'm having a little problem using the STL function 'adjacent_difference' with my own std::binary_function-derived function. I've created a simple main.cpp (below) to show the problem. When I hit compile I get: error C2440: '=' : cannot convert from 'std::iterator_traits<_Iter>::value_type' to 'std::allocator<_Ty>::value_type' Does anyone know, where have I erred? All the best, Graham
#include <iostream>
#include <deque>
#include <vector>
#include <numeric>
#include <functional>
#include <Wm3Vector3.h> // http://www.geometrictools.com/Foundation/Math/Wm3Vector3.h
template < class TReal >
class Vec3DistanceBetween : public std::binary_function< Wm3::Vector3< TReal >, Wm3::Vector3< TReal >, TReal >
{
public:
result_type operator()( const first_argument_type &arg1, const second_argument_type &arg2 ) const
{
return ( arg2 - arg1 ).Length();
}
};
int main()
{
std::vector< float >::iterator Iter;
std::vector< Wm3::Vector3< float > > in;
std::vector< float > out;
adjacent_difference( in.begin(), in.end(), out.begin(), Vec3DistanceBetween< float >() );
return 1;
}