gpt4 book ai didi

c++ - 旧代码不能用新的 CGAL 版本编译(错误 : invalid application of ‘sizeof’ )

转载 作者:行者123 更新时间:2023-11-28 04:50:29 24 4
gpt4 key购买 nike

几年前我写了这篇用 CGAL-4.1 编译的文章:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/basic.h>
#include <CGAL/Search_traits_2.h>
#include <CGAL/Search_traits_adapter.h>
#include <CGAL/Kd_tree.h>
#include <CGAL/Fuzzy_iso_box.h>
#include <CGAL/Timer.h>
#include <boost/iterator/zip_iterator.hpp>

#include <utility>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <omp.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef boost::tuple < Point_2, int > Point_and_int;

//definition of the property map
class My_point_property_map
{
public:
typedef Point_2 value_type;
typedef const value_type& reference;
typedef const Point_and_int& key_type;
typedef boost::lvalue_property_map_tag category;
// typedef boost::readable_property_map_tag category;


};

//get function for the property map
My_point_property_map::reference
get (My_point_property_map, My_point_property_map::key_type p)
{
return boost::get <0> (p);
}...

如果使用 typedef boost::readable_property_map_tag category; 编译 (CGAL-4.5) 会出现以下错误:

In file included from /usr/include/CGAL/assertions.h:36:0, from /usr/include/CGAL/basic.h:42, from /usr/include/CGAL/Cartesian/Cartesian_base.h:28, from /usr/include/CGAL/Simple_cartesian.h:28, from /usr/include/CGAL/Exact_predicates_inexact_constructions_kernel.h:28, from /home/bruno/ex_cgal/New_Vellin_omp.cpp:5: /usr/include/CGAL/Search_traits_adapter.h: In instantiation of ‘class CGAL::Search_traits_adapter, int>, My_point_property_map, CGAL::Search_traits_2 >’:/home/bruno/ex_cgal/New_Vellin_omp.cpp:56:38: required from here /usr/include/CGAL/Search_traits_adapter.h:75:3: error: invalid application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE’ BOOST_STATIC_ASSERT( ( boost::is_same< boost::lvalue_property_map_tag,

如果使用 typedef boost::lvalue_property_map_tag category; 编译 (CGAL-4.5),它可以工作。

请注意,使用 CGAL-4.1 和 typedef boost::readable_property_map_tag 类别; 没有编译错误。

缺少代码:

typedef CGAL::Search_traits_2 < Kernel > Traits_base;
typedef CGAL::Search_traits_adapter < Point_and_int, My_point_property_map, Traits_base > Traits;
typedef CGAL::Fuzzy_iso_box < Traits > Fuzzy_iso_box;
typedef const CGAL::Kd_tree < Traits > Tree;

最佳答案

我发现两个版本(CGAL-4.1 vs CGAL-4.5)之间的 header CGAL 存在差异,/usr/include/CGAL/Search_traits_adapter.h在 ver_4.1 中没有声明:

BOOST_STATIC_ASSERT( ( boost::is_same< boost::lvalue_property_map_tag, typename boost::property_traits::category>::value ) );产生错误。

关于c++ - 旧代码不能用新的 CGAL 版本编译(错误 : invalid application of ‘sizeof’ ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48319771/

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