Boost logo

Boost :

Subject: Re: [boost] [local] Review
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-11-18 16:27:10

On Fri, Nov 18, 2011 at 12:02 PM, Thomas Heller

> On 11/18/2011 01:27 PM, Jeffrey Lee Hellrung, Jr. wrote:
>> Thanks for the review, Thomas! I just have a couple comments.
>> On Fri, Nov 18, 2011 at 10:49 AM, Thomas Heller
>> <thom.heller_at_[hidden]>wrote:
>> [...]
>>> Local Blocks:
>>> I can't see the value in that one. The example in the documentation
>>> doesn't help either, as those things are easily detected by any modern
>>> compiler, with the appropriate warning levels (ok, not in the assert
>>> case,
>>> but for other boolean contexts at least gcc does).
>> I *believe* there has been an instance in my own code where I had to
>> const_cast a range to coerce a range algorithm to use const_iterator's for
>> efficiency reasons...or something like that. I don't remember the details
>> of the situation, but I can imagine instances where const access to an
>> object would be more efficient than mutable access, e.g., if mutable
>> access
>> via operator[] must return a proxy. It can be difficult to guarantee in
>> general that the compiler would optimize a
>> syntactically-mutable-**semantically-const access into the equivalent
>> syntactically-const access.
> I see. But why do you need local blocks to achieve that?

I don't. I could just const_cast use of the variable everywhere I want it
const-qualified. Or define a reference-to-const to the same effect. ...or
use a local block.

You just sounded like you were angling for a legitimate use case for local
blocks, and I tried to supply a plausible (if rare) one.

- Jeff

Boost list run by bdawes at, gregod at, cpdaniel at, john at