【发布时间】:2014-08-20 00:18:44
【问题描述】:
我想将boost::model::polygon 转换为boost::model::multi_point,这是我的实现:
namespace bg = boost::geometry;
typedef bg::model::point<double, 3, bg::cs::cartesian> point3d;
bg::model::multi_point<point3d> result;
std::function<void(point3d)> appendPoint = [result](point3d point){
bg::append(result, point);
};
bg::for_each_point(polygon, appendPoint);
但是这段代码给了我一个错误:
error: passing ‘boost::remove_reference<const boost::geometry::model::multi_point<boost::geometry::model::point<double, 3ul, boost::geometry::cs::cartesian> > >::type {aka const boost::geometry::model::multi_point<boost::geometry::model::point<double, 3ul, boost::geometry::cs::cartesian> >}’ as ‘this’ argument of ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = boost::geometry::model::point<double, 3ul, boost::geometry::cs::cartesian>; _Alloc = std::allocator<boost::geometry::model::point<double, 3ul, boost::geometry::cs::cartesian> >; std::vector<_Tp, _Alloc>::value_type = boost::geometry::model::point<double, 3ul, boost::geometry::cs::cartesian>]’ discards qualifiers [-fpermissive]
如果我理解正确,这种错误表明 const 正确性存在问题。但我真的不知道,关于const 的这段代码有什么问题。谁能解释一下,我的错误在哪里,并且修复它很热?
【问题讨论】:
标签: c++ lambda boost-geometry