Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] c++14 compatibility: CGAL::get and std::get ambiguity

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] c++14 compatibility: CGAL::get and std::get ambiguity


Chronological Thread 
  • From: Marc Glisse <>
  • To:
  • Subject: Re: [cgal-discuss] c++14 compatibility: CGAL::get and std::get ambiguity
  • Date: Tue, 11 Aug 2015 04:48:27 +0200 (CEST)

On Fri, 7 Aug 2015, Martin Seemann wrote:

I recently came across a regression, which is demonstrated by the example below:

#include <CGAL/Simple_cartesian.h>
int main() {
typedef CGAL::Simple_cartesian<double> K;
CGAL::Line_3<K> line(CGAL::Point_3<K>(0, 0, 0), CGAL::Point_3<K>(1, 1, 1));
std::cout << line.point(0) << std::endl;
return 0; }

Using GCC 5.2.0 (Archlinux), the above example compiles fine with -std=c++11 but when switching to -std=c++14, the compiler starts complaining about ambiguous 'get(...)' overloads in CGAL/Cartesian/Line_3.h:78.
I figured that it was caused by some c++14 additions to the standard library (http://en.cppreference.com/w/cpp/utility/pair/get, overloads 4-7).
A quick fix is to make the desired namespace explicit in CGAL/Cartesian/Line_3.h, i. e. to replace lines 78 and 83 by
return CGAL::get(base).first;
and
return CGAL::get(base).second;
respectively.
After these modifications, the above example (and also my real project) compiles fine.

https://github.com/CGAL/cgal/commit/b7f98495991ee49b2b01e64a36bb3b5c1e89a615

However, prefixing with CGAL:: in this place seems strange to me, since we are already in namespace CGAL. Furthermore, I do not understand why the std::get variants even participate in overload resolution, given that they are defined in std (I couldn't find any dangerous
'using namespace std' anywhere in the CGAL code base either).

Maybe someone with a deeper understanding of the language can give his opinion if this situation should be corrected in CGAL or in the standard library.
BTW: The error also happens with clang (v3.6.2)
(My CGAL version is 4.6.2)

ADL means that if the arguments involve a type defined in namespace std (even indirectly), std::get gets to participate.

--
Marc Glisse



Archive powered by MHonArc 2.6.18.

Top of Page