Boost 1.65.1 geometry distance strategy compile error with Visual Studio 2017

倾然丶 夕夏残阳落幕 提交于 2021-01-26 09:38:13

问题


When trying to compile my project with new version of boost 1.65.1, I get the following error:

C:\Users\twozn\Dev\soundtoolkit\stk\libraries\boost/geometry/strategies/distance.hpp(101): error C2664: 'int boost::mpl::assertion_failed<false>(boost::mpl::assert<false>::type)': cannot convert argument 1 from 'boost::mpl::failed ************(__cdecl boost::geometry::strategy::distance::services::default_strategy<boost::geometry::point_tag,boost::geometry::segment_tag,boost::geometry::model::point<float,2,boost::geometry::cs::cartesian>,boost::geometry::model::point<float,2,boost::geometry::cs::cartesian>,boost::geometry::cartesian_tag,boost::geometry::cartesian_tag,void>::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE_COMBINATION::* ***********)(boost::mpl::assert_::types<Point1,Point2,CsTag1,CsTag2>)' to 'boost::mpl::assert<false>::type'
1>        with
1>        [
1>            Point1=boost::geometry::model::point<float,2,boost::geometry::cs::cartesian>,
1>            Point2=boost::geometry::model::point<float,2,boost::geometry::cs::cartesian>,
1>            CsTag1=boost::geometry::cartesian_tag,
1>            CsTag2=boost::geometry::cartesian_tag
1>        ]

which is triggered by line

std::vector<Value> results;
rtree.query(boost::geometry::index::nearest(Point(p.x, p.y), 1), std::back_inserter(results));

where the rtree above is defined as

using Point = boost::geometry::model::point<float, 2,boost::geometry::cs::cartesian>;
using Segment = boost::geometry::model::segment<Point>;
using Value = std::pair<Segment, size_t>;
boost::geometry::index::rtree<Value, boost::geometry::index::rstar<16>> rtree;

The assertion triggered is (boost/geometry/strategies/distance.hpp):

template
<
    typename GeometryTag1,
    typename GeometryTag2,
    typename Point1,
    typename Point2 = Point1,
    typename CsTag1 = typename cs_tag<Point1>::type,
    typename CsTag2 = typename cs_tag<Point2>::type,
    typename UnderlyingStrategy = void
>
struct default_strategy
{
    BOOST_MPL_ASSERT_MSG
        (
            false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE_COMBINATION
            , (types<Point1, Point2, CsTag1, CsTag2>)
        );
};

This compiled and worked correctly with Boost 1.64.0. The compiler is Visual Studio 2017 Update 1. What is the issue here?


回答1:


Not having access to MSVC, I could /guess/ that you need to include more headers. It could be they got indirectly included in Boost 1.64.0.

See if you can compile the following self-contained example:

Live On Coliru

#include <boost/geometry/geometry.hpp>
#include <boost/geometry/core/coordinate_system.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/index/predicates.hpp>

using Point   = boost::geometry::model::point<float, 2,boost::geometry::cs::cartesian>;
using Segment = boost::geometry::model::segment<Point>;
using Value   = std::pair<Segment, size_t>;

int main() {
    boost::geometry::index::rtree<Value, boost::geometry::index::rstar<16>> rtree;

    std::vector<Value> results;
    rtree.query(boost::geometry::index::nearest(Point(1, 2), 1), std::back_inserter(results));
}


来源:https://stackoverflow.com/questions/46156995/boost-1-65-1-geometry-distance-strategy-compile-error-with-visual-studio-2017

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!