Blob Blame History Raw
From 4aa7366fafb7a3f91cc68d4a808f5195a4aa3dcf Mon Sep 17 00:00:00 2001
From: Chow Loong Jin <hyperair@debian.org>
Date: Tue, 22 Aug 2023 15:35:56 +0800
Subject: [PATCH] Fix compilation errors with -std=gnu++17 (PR#11154)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes the following error:

[ 19%] Built target imgui
/<<PKGBUILDDIR>>/src/libslic3r/MeshBoolean.cpp: In instantiation of ‘indexed_triangle_set Slic3r::MeshBoolean::cgal::cgal_to_indexed_triangle_set(const _Mesh&) [with _Mesh = CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick> >]’:
/<<PKGBUILDDIR>>/src/libslic3r/MeshBoolean.cpp:185:53:   required from here
/<<PKGBUILDDIR>>/src/libslic3r/MeshBoolean.cpp:151:5: error: cannot bind non-const lvalue reference of type ‘CGAL::SM_Vertex_index&’ to an rvalue of type ‘boost::iterators::detail::iterator_facade_base<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick> >::Index_iterator<CGAL::SM_Vertex_index>, CGAL::SM_Vertex_index, std::random_access_iterator_tag, CGAL::SM_Vertex_index, long int, false, false>::reference’ {aka ‘CGAL::SM_Vertex_index’}
  151 |     for (auto &vi : vertices) {
      |     ^~~
/<<PKGBUILDDIR>>/src/libslic3r/MeshBoolean.cpp:156:5: error: cannot bind non-const lvalue reference of type ‘CGAL::SM_Face_index&’ to an rvalue of type ‘boost::iterators::detail::iterator_facade_base<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick> >::Index_iterator<CGAL::SM_Face_index>, CGAL::SM_Face_index, std::random_access_iterator_tag, CGAL::SM_Face_index, long int, false, false>::reference’ {aka ‘CGAL::SM_Face_index’}
  156 |     for (auto &face : faces) {
      |     ^~~
make[3]: *** [src/libslic3r/CMakeFiles/libslic3r_cgal.dir/build.make:121: src/libslic3r/CMakeFiles/libslic3r_cgal.dir/MeshBoolean.cpp.o] Error 1

Signed-off-by: Jan Staněk <jstanek@redhat.com>
---
 src/libslic3r/MeshBoolean.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libslic3r/MeshBoolean.cpp b/src/libslic3r/MeshBoolean.cpp
index d76bf468c..222325739 100644
--- a/src/libslic3r/MeshBoolean.cpp
+++ b/src/libslic3r/MeshBoolean.cpp
@@ -152,12 +152,12 @@ indexed_triangle_set cgal_to_indexed_triangle_set(const _Mesh &cgalmesh)
     const auto &vertices = cgalmesh.vertices();
     int vsize = int(vertices.size());
 
-    for (auto &vi : vertices) {
+    for (const auto &vi : vertices) {
         auto &v = cgalmesh.point(vi); // Don't ask...
         its.vertices.emplace_back(to_vec3f(v));
     }
 
-    for (auto &face : faces) {
+    for (const auto &face : faces) {
         auto vtc = cgalmesh.vertices_around_face(cgalmesh.halfedge(face));
 
         int i = 0;
-- 
2.41.0