Boost logo

Boost Users :

Subject: [Boost-users] Boost.lamba compile errror....
From: Joost Kraaijeveld (J.Kraaijeveld_at_[hidden])
Date: 2009-03-29 14:18:10


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<boost::lambda::lambda_functor_base<boost::lambda::action<3, boost::lambda::function_action<3, boost::lambda::detail::unspecified> >, boost::tuples::tuple<MatrixVector<double> (MatrixVector<double>::* const)(const MatrixVector<double>&)const, const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, const MatrixVector<double>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >’ has no member named ‘length’

The error "has no member named ‘length’" is unexpected: a MatrixVector ,
the return value of the global operator is a MatrixVector, has a member
length() . I have tried several syntax possibilities but with no luck.

Does anyone has any suggestions?

TIA

-- 
Groeten,
Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
web: www.askesis.nl

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net