Boost logo

Geometry :

Subject: [geometry] for_each_point( ) and lambdas
From: Vladimir Petrovic (vpetrovic_at_[hidden])
Date: 2012-11-06 11:34:23

I'm trying to use the following code (boost 1.51.0) under Microsoft VC

boost::geometry::for_each_point( *this, [size](_TPoint<T>& pt) { pt +=
size; } );

The compiler gives an error that lambda type doesn't have operator=:

error C2582: 'operator =' function is unavailable in
boost_1_51_0\boost\geometry\multi\algorithms\for_each.hpp 54

The problem is in the for_each.hpp:
struct for_each_multi
    static inline Functor apply(
                    typename add_const_if_c<IsConst,
MultiGeometry>::type& multi,
                    Functor f)
        for(BOOST_AUTO_TPL(it, boost::begin(multi)); it !=
boost::end(multi); ++it)
            f = Policy::apply(*it, f);
        return f;

The code tries to assign to functor: f = Policy::apply(*it, f);

It seems correct to me that VC doesn't allow operator= for lambdas. On
the other hand, it's natural to use lambda with for_each_point( ). Is
there any other way to use for_each_point() or something similar with
funktor which doesn't have operator= (like lambda) ?

best regards,

Vladimir Petrovic | vpetrovic_at_[hidden]
think-cell Software GmbH | Chausseestr. 8/E | 10115 Berlin | Germany | phone +49 30 666473-10 | US phone +1 800 891 8091
Amtsgericht Berlin-Charlottenburg, HRB 85229 | European Union VAT Id DE813474306
Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl

Geometry list run by mateusz at