Boost logo

Boost :

Subject: Re: [boost] [local_function] any interest in a LocalFunction library?
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2010-09-14 18:42:40


On 9/14/2010 2:25 PM, John Bytheway wrote:
> On 14/09/10 03:52, Lorenzo Caminiti wrote:
>> I agree, if the macro is named `..._FUNCTION` then `return` is not
>> confusing. What is the use case for unnamed local functions? Is it
>> just the breakable feature?
[...]
>> I am not sure of the utility of unnamed local functions but if there
>> is a clear use case for them, they would be really trivial to
>> implement. I think what we need to find is a good use case for this.
>
> One thing that occurs to me is the possibly utility of unnamed local
> functions which are not void. For example, I sometimes want to have a
> variable which has to be non-const for a bit while I initialize it, but
> is then const (in principle). It would be nice to allow enforcing this
> (somewhat the reverse of BOOST_BLOCK_CONST).
[...]
> Another closely related issue is when you want to have an object briefly
> to pass to the constructor of another but destroy it soon afterwards
> (i.e. not have the order of construction be the reverse order of
> destruction); local functions could help there too. Right now I might do
[...]

I think these are worthy use cases. I definitely find myself in these
situations occasionally.

- Jeff


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