Boost logo

Boost Users :

From: chun ping wang (cablepuff_at_[hidden])
Date: 2007-12-19 15:28:49


Hi, does anyone know whats wrong with this code. It doesn't compile on
gcc-mingw 4.1.2.

it works on msvc visual studio 2005.

code:
template <class InputIterator>
typename InputIterator::difference_type kmean::getClusterIndex(InputIterator
first, InputIterator last)
{
    typedef typename InputIterator::value_type T;
    BOOST_STATIC_ASSERT(boost::is_floating_point<T>::value);
    #ifdef __DEBUG__
            boost::prof::profiler p;
    #endif
    T min(std::numeric_limits<T>::max());
    typedef typename InputIterator::difference_type diff_type;
    diff_type index(0);
    diff_type currentIndex(0);
    std::for_each(first, last,
        (
        boost::lambda::if_then(boost::lambda::_1 < boost::lambda::var(min),
            (
                boost::lambda::var(min) = boost::lambda::_1,
                boost::lambda::var(index) = boost::lambda::var(currentIndex)
            )),
            ++boost::lambda::var(currentIndex)
        )
    );
    #ifdef __DEBUG__
        std::cerr << "finish getClusterIndex\n";
    #endif
    return index;
}

error message:

C:/Boost/include/boost/lambda/detail/lambda_functor_base.hpp: In member
function 'boost::lambda::identity<ptrdiff_t&>&
boost::lambda::identity<ptrdiff_t&>::operator=(const
boost::lambda::identity<ptrdiff_t&>&)':
C:/Boost/include/boost/lambda/detail/lambda_functor_base.hpp:23:
instantiated from 'typename InputIterator::difference_type
kmean::getClusterIndex(InputIterator, InputIterator) [with InputIterator =
__gnu_cxx::__normal_iterator<double*, std::vector<double,
std::allocator<double> > >]'
./cs522/c++/kmeanMain.cpp:70: instantiated from here
C:/Boost/include/boost/lambda/detail/lambda_functor_base.hpp:23: error:
non-static reference member 'ptrdiff_t&
boost::lambda::identity<ptrdiff_t&>::elem', can't use default assignment
operator
C:/Boost/include/boost/lambda/detail/lambda_functors.hpp: In member function
'boost::lambda::lambda_functor<boost::lambda::identity<ptrdiff_t&> >&
boost::lambda::lambda_functor<boost::lambda::identity<ptrdiff_t&>
>::operator=(const
boost::lambda::lambda_functor<boost::lambda::identity<ptrdiff_t&> >&)':
C:/Boost/include/boost/lambda/detail/lambda_functors.hpp:113: note:
synthesized method 'boost::lambda::identity<ptrdiff_t&>&
boost::lambda::identity<ptrdiff_t&>::operator=(const
boost::lambda::identity<ptrdiff_t&>&)' first required here
./cs522/c++/def/kmeandef.hpp: In function 'typename
InputIterator::difference_type kmean::getClusterIndex(InputIterator,
InputIterator) [with InputIterator = __gnu_cxx::__normal_iterator<double*,
std::vector<double, std::allocator<double> > >]':
./cs522/c++/def/kmeandef.hpp:406: note: synthesized method
'boost::lambda::lambda_functor<boost::lambda::identity<ptrdiff_t&> >&
boost::lambda::lambda_functor<boost::lambda::identity<ptrdiff_t&>
>::operator=(const
boost::lambda::lambda_functor<boost::lambda::identity<ptrdiff_t&> >&)' first
required here
make: *** [project/kmeanMain.o] Error 1



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