gpt4 book ai didi

C++ 11和 boost 几何

转载 作者:行者123 更新时间:2023-11-28 06:46:16 25 4
gpt4 key购买 nike

我开始使用 c++11 并尝试使用 boost geometry 运行一些示例代码

#include <iostream>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>

BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)


int main()
{
typedef boost::tuple<double, double> point;
typedef boost::geometry::model::polygon<point> polygon;

polygon poly;
boost::geometry::read_wkt("polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0"
", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))", poly);

polygon hull;
boost::geometry::convex_hull(poly, hull);

using boost::geometry::dsv;
std::cout
<< "polygon: " << dsv(poly) << std::endl
<< "hull: " << dsv(hull) << std::endl
;


return 0;
}

但是我有以下错误

/boost/include/boost/geometry/algorithms/detail/recalculate.hpp: In statischer Elementfunktion »static void boost::geometry::detail::recalculate::polygon_to_polygon::apply(Polygon1&,

const Polygon2&, const Strategy&)«: boost/include/boost/geometry/algorithms/detail/recalculate.hpp:145:24: Fehler: »it_source« is not defined

boost/include/boost/geometry/algorithms/detail/recalculate.hpp:146:24: Fehler: »it_dest« is not defined

有人知道为什么这不起作用吗?

对不起,我忘了添加我的系统。我在 GCC 4.6.3 和 boost 1.55 中使用 64 位 Mint 13

谢谢你的帮助

最佳答案

显然是你的编译器

  • 是 C++11 挑战
  • 配置错误

BOOST_AUTO_TPL 无法正常工作:

    BOOST_AUTO_TPL(it_source, boost::begin(rings_source));
BOOST_AUTO_TPL(it_dest, boost::begin(rings_dest));

在 c++11 编译器上它会展开为

auto it_source = boost::begin(rings_source);
auto it_dest = boost::begin(rings_dest);

但是,如果您在 c++03 模式下编译它(例如,在 gcc/clang 上没有 -std=c++11),您可能会得到 it_sourceit_dest 不是有效类型(此外,其余的语句/声明格式不正确)

关于C++ 11和 boost 几何,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24937744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com