Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] problem with BOOST_RESULT_OF_USE_DECLTYPE

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] problem with BOOST_RESULT_OF_USE_DECLTYPE


Chronological Thread 
  • From: Cody Rose <>
  • To:
  • Subject: Re: [cgal-discuss] problem with BOOST_RESULT_OF_USE_DECLTYPE
  • Date: Wed, 30 Jan 2013 11:22:40 -0800

On 1/30/2013 2:48 AM, Philipp Moeller wrote:
"Sebastien Loriot (GeometryFactory)"
<>
writes:

On 01/30/2013 11:39 AM, Philipp Moeller wrote:
Cody
Rose<>
writes:

Hello,

With CGAL 4.1 I am unable to use the Nef_polyhedron_3 package with
BOOST_RESULT_OF_USE_DECLTYPE defined. I am using:
You have to define BOOST_RESULT_OF_USE_DECLTYPE because your compiler
does not implement a fully conforming decltype. (AFAIK, the only
compiler that currently does is clang 3.2).
I guess you meant you can't define BOOST_RESULT_OF_USE_DECLTYPE ?
You can define it yourself, it is just not guaranteed to work for every
library (as you can see here). This was even one of the fixes for using
Boost.Range with lambdas.

Yes, this is exactly what I was trying to do, as I demonstrated: get parts of Boost.Range to work with lambdas in MSVC 2010. That kind of thing is what the macro is for.


CGAL 4.1
the CORE numeric library, along with its dependencies (GMP etc)
Boost 1.47
Visual Studio 2010

The problem does *not* appear in CGAL 3.9.
CGAL 3.9 didn't use result_of. That's why you don't see the problem.

The following code reproduces the problem for me:

// This is the problematic define.
#define BOOST_RESULT_OF_USE_DECLTYPE

#include<vector>

#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

#include<CGAL/Cartesian.h>
#include<CGAL/CORE_Expr.h>
#include<CGAL/Nef_polyhedron_3.h>

typedef CORE::Expr NT;
typedef CGAL::Cartesian<NT> K;
typedef CGAL::Nef_polyhedron_3<K> nef_polyhedron_3;

int main() {
std::vector<int> a(0, 3);
a[0] = 1;
a[1] = 2;
a[3] = 3;
std::vector<int> b;

// With BOOST_RESULT_OF_USE_DECLTYPE defined, the following line
causes an error.
nef_polyhedron_3 foo;
This is because MSVC decltype triggers instantiation prematurely.

// Without BOOST_RESULT_OF_USE_DECLTYPE defined, the following
line causes an error.
This is because built-in lambdas require a decltype based result_of.

boost::copy(a | boost::adaptors::transformed([](int x) { return x
* 2; }), std::back_inserter(b)); return 0; }
It would be nice if both worked together, even with a broken
decltype. If I remember correctly there was a work-around involving two
Type_equality_wrappers when instantiating kernels.

Yeah, I was hoping there would be a workaround either for my code or maybe even put into CGAL at some point. I can totally understand not wanting to work around a weird corner-case bug in a compiler that isn't even the latest version, though. Oh well! All it seems to really be affecting is boost::adaptors::transformed.

Thanks,
Cody



Archive powered by MHonArc 2.6.18.

Top of Page