
29 Mar
2009
29 Mar
'09
7:26 p.m.
AMDG Joost Kraaijeveld wrote:
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; ... }
<snip> 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() );
You have to use bind for length exactly like you used bind for difference. In Christ, Steven Watanabe