首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Boost几何: assertion_failed误差C++

Boost几何: assertion_failed误差C++
EN

Stack Overflow用户
提问于 2020-02-11 12:53:19
回答 1查看 754关注 0票数 3

为了使用boost几何类型,我有以下头文件:

代码语言:javascript
复制
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/geometries/register/point.hpp>

using namespace boost::geometry;
using namespace detail::assign;

typedef model::d2::point_xy<double> point_xy;
typedef model::polygon<point_xy> polygon;
typedef model::multi_polygon<polygon> multi_polygon;
typedef model::box<point_xy> box;

在编译试图使用这些类型的文件时,我会得到一个大量的编译器错误:

代码语言:javascript
复制
In file included from src/geometry.cpp:11:
In file included from src/../include/geometry.hpp:9:
In file included from /usr/local/include/boost/geometry.hpp:17:
In file included from /usr/local/include/boost/geometry/geometry.hpp:26:
In file included from /usr/local/include/boost/geometry/core/coordinate_dimension.hpp:23:
/usr/local/include/boost/geometry/core/point_type.hpp:45:5: error: no matching function for call to 'assertion_failed'
    BOOST_MPL_ASSERT_MSG
    ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/mpl/assert.hpp:454:51: note: expanded from macro 'BOOST_MPL_ASSERT_MSG'
#   define BOOST_MPL_ASSERT_MSG( c, msg, types_ ) \
                                                  ^
/usr/local/include/boost/mpl/assert.hpp:440:9: note: expanded from macro '\
BOOST_MPL_ASSERT_MSG_IMPL'
        boost::mpl::assertion_failed<(c)>( BOOST_PP_CAT(mpl_assert_arg,counter)::assert_arg() ) \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/mpl/assert.hpp:60:58: note: expanded from macro '\
BOOST_MPL_AUX_ASSERT_CONSTANT'
#   define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) enum { expr }
                                                         ^~~~
/usr/local/include/boost/geometry/core/point_type.hpp:65:30: note: in instantiation of template class
      'boost::geometry::traits::point_type<std::__1::vector<float, std::__1::allocator<float> > >' requested here
            typename traits::point_type<Geometry>::type
                             ^
/usr/local/include/boost/geometry/core/coordinate_type.hpp:58:22: note: in instantiation of template class 'boost::geometry::core_dispatch::point_type<void,
      std::__1::vector<float, std::__1::allocator<float> > >' requested here
    typedef typename point_type<GeometryTag, Geometry>::type point_type;
                     ^
/usr/local/include/boost/geometry/core/coordinate_type.hpp:88:37: note: in instantiation of template class 'boost::geometry::core_dispatch::coordinate_type<void,
      std::__1::vector<float, std::__1::allocator<float> > >' requested here
    typedef typename core_dispatch::coordinate_type
                                    ^
/usr/local/include/boost/geometry/core/access.hpp:269:17: note: in instantiation of template class 'boost::geometry::coordinate_type<std::__1::vector<float,
      std::__1::allocator<float> > >' requested here
inline typename coordinate_type<Geometry>::type get(Geometry const& geometry
                ^
/usr/local/include/boost/geometry/algorithms/detail/convert_point_to_point.hpp:42:74: note: while substituting deduced template arguments into function template
      'get' [with Dimension = 0, Geometry = std::__1::vector<float, std::__1::allocator<float> >]
        set<Dimension>(destination, boost::numeric_cast<coordinate_type>(get<Dimension>(source)));
                                                                         ^
/usr/local/include/boost/geometry/algorithms/detail/convert_point_to_point.hpp:58:76: note: (skipping 3 contexts in backtrace; use -ftemplate-backtrace-limit=0
      to see all)
    point_to_point<Source, Destination, 0, dimension<Destination>::value>::apply(source, destination);
                                                                           ^
/usr/local/include/boost/geometry/algorithms/append.hpp:129:45: note: in instantiation of member function
      'boost::geometry::detail::append::append_range<boost::geometry::model::ring<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian>,
      true, true, vector, allocator>, std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >, std::__1::allocator<std::__1::vector<float,
      std::__1::allocator<float> > > > >::apply' requested here
            append_range<ring_type, Range>::apply(
                                            ^
/usr/local/include/boost/geometry/algorithms/append.hpp:296:51: note: in instantiation of member function
      'boost::geometry::detail::append::range_to_polygon<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double,
      boost::geometry::cs::cartesian>, true, true, std::vector, std::vector, std::allocator, std::allocator>, std::__1::vector<std::__1::vector<float,
      std::__1::allocator<float> >, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > > >::apply' requested here
        dispatch::append<Geometry, RangeOrPoint>::apply(geometry,
                                                  ^
/usr/local/include/boost/geometry/algorithms/append.hpp:371:22: note: in instantiation of function template specialization
      'boost::geometry::resolve_variant::append<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian>,
      true, true, std::vector, std::vector, std::allocator, std::allocator> >::apply<std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >,
      std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > > >' requested here
                   ::apply(geometry, range_or_point, ring_index, multi_index);
                     ^
/usr/local/include/boost/geometry/algorithms/assign.hpp:75:15: note: in instantiation of function template specialization
      'boost::geometry::append<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian>, true, true,
      std::vector, std::vector, std::allocator, std::allocator>, std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >,
      std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > > >' requested here
    geometry::append(geometry, range, -1, 0);
              ^
src/geometry.cpp:213:5: note: in instantiation of function template specialization
      'boost::geometry::assign_points<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian>, true, true,
      std::vector, std::vector, std::allocator, std::allocator>, std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >,
      std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > > >' requested here
    assign_points(poly, shape.border);
    ^
/usr/local/include/boost/mpl/assert.hpp:83:5: note: candidate function not viable: no known conversion from 'boost::mpl::failed
      ************(boost::geometry::traits::point_type<std::__1::vector<float, std::__1::allocator<float> >
      >::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(types<std::__1::vector<float, std::__1::allocator<float> > >)' to 'typename assert<false>::type'
      (aka 'mpl_::assert<false>') for 1st argument
int assertion_failed( typename assert<C>::type );
    ^
In file included from src/geometry.cpp:11:
In file included from src/../include/geometry.hpp:9:
In file included from /usr/local/include/boost/geometry.hpp:17:
In file included from /usr/local/include/boost/geometry/geometry.hpp:28:
/usr/local/include/boost/geometry/core/coordinate_type.hpp:43:5: error: no matching function for call to 'assertion_failed'
    BOOST_MPL_ASSERT_MSG
    ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/mpl/assert.hpp:454:51: note: expanded from macro 'BOOST_MPL_ASSERT_MSG'
#   define BOOST_MPL_ASSERT_MSG( c, msg, types_ ) \

我见过的帖子,其中他们没有注册元组-然而,我没有使用元组或任何特殊类型的点-我只是尝试使用内置的几何类型。为什么这个错误还在发生?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-11 21:31:39

正如您所看到的,发布的代码本身并不是一个问题:住在Coliru

所以,一定有别的干扰。我有三个预感:

  1. 这是你的代码中没有发布的地方。错误的原因是在../src/geometry.cpp中(而不是Boost库): Assign_points(聚,shape.border); 这为您提供了关于如何简化为MCVE的好主意。
  2. 你有预处理问题。尝试对源代码进行预处理,看看出现在错误消息中的代码是否可疑。 这方面的一个经典示例是,如果其他包含的标头定义了令牌(如#define min(a,b) ...或其他常用的单词)。 附带注意:这是关于代码卫生的。相关的注意事项是using namespace在您所显示的代码片段中的出现。这只会引发名称空间冲突或意外效果。
  3. 稍微相关:干扰的来源可能与预编译头有关。尝试禁用这些,或确保您知道PCH头中的内容(特别是在MSVC上(通常使用stdafx.h),预编译头具有一些潜在的惊人效果)。

更新

我想我注意到了:src/griy.cpp:213:5调用中的违规代码:

代码语言:javascript
复制
assign_points(poly, shape.border);

类型:poly

代码语言:javascript
复制
boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian>, true, true, std::vector, std::vector, std::allocator, std::allocator>,

这就是上面所显示的polygon类型。但shape.border是:

代码语言:javascript
复制
std::__1::vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>>>

那只是vector<std::vector<float> >。那不是支撑几何。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60169280

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档