Hi,
I want to sort a Matrix of Vectors according to their difference in
length to some arbitrary Vector. e.g:
template< typename T>
struct MatrixVector : std::vector< T >
{
...
double length() const;
MatrixVector<T> difference(const MatrixVector< T>& rhs) const;
...
}
template< typename T >
MatrixVector< T > operator-(const MatrixVector< T >& lhs, const MatrixVector< T >& rhs)
{
return lhs.difference(rhs);
}
typedef MatrixVector< double > Vector;
typedef std::vector< Vector > Matrix;
...
Matrix matrix;
matrix.push_back(some vectors); // multiple!
std::sort( matrix.begin(),
matrix.end(),
boost::lambda::bind(&Vector::difference, boost::lambda::_1, observation).length()
<
boost::lambda::bind(&Vector::difference, boost::lambda::_2, observation).length()
);
Compiling this gives (GCC 4.3.2, Debian Lenny, Boost 1.35):
g++ -DHAVE_CONFIG_H -I. -I../../src -I/usr/include -g -O2 -MT Main.o -MD -MP -MF .deps/Main.Tpo -c -o Main.o ../../src/Main.cpp
../../src/Main.cpp: In function ‘int main(int, char**)’:
../../src/Main.cpp:101: error: ‘const class boost::lambda::lambda_functor