Boost logo

Boost :

Subject: Re: [boost] [LA] vector_traits for setters
From: Barend Gehrels (barend_at_[hidden])
Date: 2010-05-11 09:07:08


Hi Emil,

Emil Dotchevski wrote:
> On Mon, May 10, 2010 at 9:10 PM, Barend Gehrels <barend_at_[hidden]> wrote:
>
>> We did exactly the same for Boost.Geometry (long ago). First have
>> non-const-ref getters and lateron moved to setters... Seems it cannot be
>> avoided.
>>
>
> I'm interested to know why did you move to setters.
>
For the same reason as you did. Some classes do not support a public
non-const reference and have a function like "set".

I dived into old correspondations about this.

Quoted (from Bruno):
> - the problem is at least technically solvable by returning an
> assigner, that is an object with a reference to the point and that has
> the actual setting operation in its operator=.

But then:

> The problem is that you can state:
> double& d = geometry::get(p);
> ......
> lateron:
> d = 5;
>

So we decided to move to get/set to avoid this (maybe uncommon)
scenario. Boost.Polygon does the same thing.

Regards, Barend


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk