我有一個數據結構:初始化向量的元組類成員初始化列表
using Delaunay = CGAL::Delaunay_triangulation_3<K, Tds>;
using Cell_handle = Delaunay::Cell_handle;
using Vertex_handle = Delaunay::Vertex_handle;
using Edge_handle = std::tuple<Cell_handle, std::uintmax_t, std::uintmax_t>;
using geometry_tuple = std::tuple<std::vector<Cell_handle>,
std::vector<Cell_handle>,
std::vector<Cell_handle>,
std::vector<Edge_handle>,
std::uintmax_t,
std::vector<Vertex_handle>>;
,我想在一個默認的構造函數來初始化:
struct SimplicialManifold {
/// Default constructor with proper initialization
SimplicialManifold()
: triangulation{std::make_unique<Delaunay>()},
geometry{std::make_tuple(0, 0, 0, 0, 0, 0)} {}
std::unique_ptr<Delaunay> triangulation;
///< std::unique_ptr to the Delaunay triangulation
geometry_tuple geometry;
///< The geometric structure of the triangulation
};
上面的代碼工作在Apple LLVM V7.3.0(clang-703.0.29),但在GCC 5.2中失敗,帶有大量模板編譯器goo:
../src/S3Triangulation.h: In constructor ‘SimplicialManifold::SimplicialManifold()’../src/S3Triangulation.h:493:55: error: no matching function for call to
‘std::tuple<std::vector<CGAL::CCC_internal::CCC_iterator<CGAL::Concurrent_compact_container<CGAL::Triangulation_cell_base_with_info_3<long unsigned int, CGAL::Epick, CGAL::Triangulation_cell_base_3<CGAL::Epick, CGAL::Triangulation_ds_cell_base_3<CGAL::Triangulation_data_structure_3<CGAL::Triangulation_vertex_base_with_info_3<long unsigned int, CGAL::Epick, CGAL::Triangulation_vertex_base_3<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_3<void> > >, CGAL::Triangulation_cell_base_with_info_3<long unsigned int, CGAL::Epick, CGAL::Triangulation_cell_base_3<CGAL::Epick, CGAL::Triangulation_ds_cell_base_3<void> > >, CGAL::Parallel_tag> > > >, tbb::scalable_allocator<CGAL::Triangulation_cell_base_with_info_3<long unsigned int, CGAL::Epick, CGAL::Triangulation_cell_base_3<CGAL::Epick, CGAL::Triangulation_ds_cell_base_3<CGAL::Triangulation_data_structure_3<CGAL::Triangulation_vertex_base_with_info_3<long unsigned int, CGAL::Epick, CGAL::Triangulation_vertex_base_3<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_3<void> > >, CGAL::Triangulation_cell_base_with_info_3<long unsigned int, CGAL::Epick, CGAL::Triangulation_cell_base_3<CGAL::Epick, CGAL::Triangulation_ds_cell_base_3<void> > >, CGAL::Parallel_tag> > > > > >, false>, std::allocator<CGAL::CCC_internal::CCC_iterator<CGAL::Concurrent_compact_container<CGAL::Triangulation_cell_base_with_info_3<long unsigned int, CGAL::Epick, CGAL::Triangulation_cell_base_3<CGAL::Epick,
(有問題的代碼是https://github.com/acgetchell/CDT-plusplus/blob/functional/src/S3Triangulation.h開始上線467)
我看着初始化列表,但是這些不工作:如何做到這一點,讓GCC快樂
geometry{std::initializer_list<std::vector<Cell_handle>,
std::vector<Cell_handle>,
std::vector<Cell_handle>,
std::vector<Edge_handle>,
std::uintmax_t,
std::vector<Vertex_handle>>({0, 0, 0, 0, 0, 0})
} {}
建議?
你用-std = C++ 11標誌編譯過嗎? – bashrc
是的,實際上使用-std = C++ 1y –
'tuple'值 - 無論如何都初始化它的元素,所以這是多餘的。 –