提升几何体:assertion_failed错误C++
Boost Geometry: assertion_failed error C++
我有以下头文件来使用提升几何类型:
#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;
编译尝试使用这些类型的文件时,我收到一个巨大的编译器错误:
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_ )
我看过这篇文章,他们没有注册元组 - 但是,我没有使用元组或任何特殊类型的点 - 我只是尝试使用内置的几何类型。为什么仍然发生此错误?
如您所见,发布的代码本身不是问题:Live On Coliru。
所以,一定有别的东西在干扰。我有三种预感:
-
它位于代码中的其他地方,您没有发布。错误的原因在
../src/geometry.cpp
(不是 Boost 库(:assign_points(poly, shape.border);
这为您提供了有关如何减少到 MCVE 的好主意。
-
您有预处理器问题。尝试预处理您的源代码,看看错误消息中出现的任何代码是否看起来可疑。
一个典型的例子是,如果其他包含的标头定义了
#define min(a,b) ...
或其他常用单词等标记。旁注:这是关于代码卫生的。相关说明是显示的代码片段中
using namespace
的外观。这只会引起命名空间冲突或意外影响。 -
稍微相关:干扰源可能与预编译的标头有关。尝试禁用这些或确保您知道PCH标头中的内容(特别是在MSVC(通常使用
stdafx.h
(预编译标头具有一些潜在的令人惊讶的效果(
更新
我想我发现了它:src/geometry.cpp:213:5 中的违规代码调用:
assign_points(poly, shape.border);
类型:poly
是
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
是:
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> >
.这不是受支持的几何图形。
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- Qt 错误消息"qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed"
- C++链接器错误 ( "Linker command failed with exit code 1" )
- libgit2:git_clone() 失败并出现"failed to create ssl object"错误
- SQL Server 2016 CLR 存储过程错误:"A system assertion check has failed"
- 代码块在尝试编译或创建新文件时出现"An assertion failed!"错误
- 如何修复"static assertion failed: template argument not an integral type"错误?
- sprintf_s() 失败并显示错误"debug assertion failed"
- 获取错误"Debug Assertion Failed"
- Xcode C++错误"linker command failed with exit code 1"
- 错误:'Failed to specialize function template' C2893 'std::invoke'
- MFC 错误仅在发布模式下"Failed to create an empty document"
- 查找发生错误"Debug assertion failed"位置
- OpenSSL 错误"assertion failed"
- 这个错误是什么"test: malloc.c:2388: sysmalloc: Assertion ... failed"
- 突然"Debug assertion failed error"错误,无需进行任何代码更改。(在C++代码中)
- 如何修复"Assertion '__pos <= size' failed"错误?
- SSL嗅探错误:"SSL Accept Failed"
- 修复(可怕的错误)! "Assertion `px != 0' failed."聊天服务器中使用 boost、std::map 和多线程
- 提升 Asio HTTPS 请求给出'certificate verify failed'错误