c++ - Boost 1.65.1 几何距离策略使用 Visual Studio 2017 编译错误

标签 c++ visual-studio boost boost-geometry

尝试使用新版本的 boost 1.65.1 编译我的项目时,出现以下错误:

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>        ]

由行触发

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

上面的rtree定义为

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;

触发的断言是(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>)
        );
};

此编译并与 Boost 1.64.0 一起正常工作。编译器是Visual Studio 2017 Update 1。这里有什么问题?

最佳答案

无法访问 MSVC,我可以/猜测/您需要包含更多 header 。可能是它们间接包含在 Boost 1.64.0 中。

看看您是否可以编译以下自包含示例:

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));
}

关于c++ - Boost 1.65.1 几何距离策略使用 Visual Studio 2017 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46156995/

相关文章:

C++ 模板,在编译时解析未定义的类型

C++ - 非指针类成员何时被销毁?

c++ - 这个浮点平方根近似是如何工作的?

c# - 如何确定是否在面板上执行了右键单击?

visual-studio - 添加 Windows 通用控件 6.0 时未注册对象库

c++ - 如何在 Visual Studio C++ 中创建自己的 .lib 文件

c++ - 如何编译 Freetype (2) 和 Harfbuzz (with visual studio) 让它们协同工作?

c++ - 灵气中如何在字符串属性开头插入一个字符

c++ - 当 ptr_vector 迭代器失效时

c++ - 使用 Boost C++ 解析 XML 文件