旧代码无法使用新的CGAL版本进行编译(错误:'sizeof'的无效应用程序)

时间:2018-01-18 11:03:36

标签: c++ boost cgal

我几年前写的这是用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),则会发生以下错误:

  

在/usr/include/CGAL/assertions.h:36:0中包含的文件中   /usr/include/CGAL/basic.h:42,来自   /usr/include/CGAL/Cartesian/Cartesian_base.h:28,来自   /usr/include/CGAL/Simple_cartesian.h:28,来自   /usr/include/CGAL/Exact_predicates_inexact_constructions_kernel.h:28,   来自/home/bruno/ex_cgal/New_Vellin_omp.cpp:5:   /usr/include/CGAL/Search_traits_adapter.h:实例化'class   CGAL :: Search_traits_adapter,int&gt ;, My_point_property_map,   CGAL :: Search_traits_2&gt;':/ home / bruno / ex_cgal / New_Vellin_omp.cpp:56:38:   从这里需要/usr/include/CGAL/Search_traits_adapter.h:75:3:   错误:'sizeof'无效应用于不完整类型'boost :: STATIC_ASSERTION_FAILURE'BOOST_STATIC_ASSERT((   升压:: is_same&LT;升压:: lvalue_property_map_tag,

如果使用typedef boost::lvalue_property_map_tag category;进行编译(CGAL-4.5),则可以正常工作。

请注意,对于CGAL-4.1和typedef boost::readable_property_map_tag category;,没有编译错误。

缺少代码:

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;

1 个答案:

答案 0 :(得分:0)

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

BOOST_STATIC_ASSERT((boost :: is_same&lt; boost :: lvalue_property_map_tag,typename boost :: property_traits :: category&gt; :: value)); 这会产生错误。