|
Geometry : |
Subject: [geometry] for_each_point and lambda with reference-captures in MSVC10
From: Volker Schöch (vschoech_at_[hidden])
Date: 2012-02-09 08:42:02
Hi again,
Thank you for your quick and helpful comments on the other issues! boost::geometry::for_each_point does not work with lamda expressions that have a reference capture. For illustration, see the code and error message below.
This may be a peculiarity of MSVC10; at least boost::for_each seems to have some special code in place that seems to work around this very issue. I have no idea what you are going to do with this information... Maybe you can fix it for the compiler, or otherwise we have one more reason to look forward to MSVC11. Probably at least you want to make sure that this is in fact a compiler-specific problem.
Regards
Volker
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/mpl/int.hpp>
using namespace boost::geometry;
void Test_Compiles() {
model::multi_polygon< model::polygon< model::point<int, 2, cs::cartesian> > > mp;
for_each_point( mp, []( model::point<int, 2, cs::cartesian> p ) { set<0>(p, 1); } );
}
void Test_Compiles2() {
int n;
model::multi_polygon< model::polygon< model::point<int, 2, cs::cartesian> > > mp;
for_each_point( mp, [n]( model::point<int, 2, cs::cartesian> p ) { set<0>(p, n); } );
}
void Test_Does_Not_Compile() {
int n;
model::multi_polygon< model::polygon< model::point<int, 2, cs::cartesian> > > mp;
for_each_point( mp, [&n]( model::point<int, 2, cs::cartesian> p ) { set<0>(p, n); } );
}
Error 1 error C2582: 'operator =' function is unavailable in '`anonymous-namespace'::<lambda0>' c:\program files (x86)\microsoft visual studio 10.0\vc\boost_1_48_0\boost\geometry\multi\algorithms\for_each.hpp 54
-- Volker Schöch | vschoech_at_[hidden] Senior Software Engineer think-cell Software GmbH | Chausseestr. 8/E | 10115 Berlin | Germany http://www.think-cell.com | 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 loskot.net