Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Re: Problems updating Poin_d's memebers

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Re: Problems updating Poin_d's memebers


Chronological Thread 
  • From: Philipp Moeller <>
  • To:
  • Subject: Re: [cgal-discuss] Re: Problems updating Poin_d's memebers
  • Date: Fri, 04 May 2012 00:10:32 +0200
  • Organization: GeometryFactory

Marc Glisse
<>
writes:

> On Thu, 3 May 2012, Philipp Moeller wrote:
>
>> I can confirm the same on a recent gcc. Looks like a bug in
>> Lazy_exact_nt to me. Point_d::operator[] returns by value as documented
>> but assignment does work for some unknown reason.
>
> Why wouldn't it?
>
> struct A {};
> A f(){return A();}
> void g(){ f()=A(); }
>
> operator= is a member function like any other.

I erroneously believed that you could only call const-member functions
on a temporary as you can only bind it to a reference-to-const. This
seems a little useless pre-C++11, but makes some sense if you have move
semantics.

Thanks for pointing it out.

>
> The operation is forbidden for builtin types, or if f returns const A
> (used to be a popular technique), or in C++11 if operator= has a '&'
> at the end of its declaration.
>
>> If operator[] should really return by value is another issue. It is
>> certainly necessary for a Homogeneous kernel, but not a Cartesian. Seems
>> wasteful in case of a ref counted NT representation.
>
> An important point of ref-counting in CGAL is not to care about
> this. It is for non-ref counted types that it is wasteful.

This still will make the ref-count increment and decrement
unnecessarily. Even if we had atomic counters we should try to avoid
that.

--
Philipp Moeller
GeometryFactory



Archive powered by MHonArc 2.6.16.

Top of Page