Boost logo

Boost :

Subject: Re: [boost] [Boost.Breakable] Any interest in a Boost Breakable library?
From: Pierre Morcello (pmorcell-cppfrance_at_[hidden])
Date: 2009-09-07 19:07:24


Thank you for this suggestion. This is extremely interesting and I did not consider it myself before (because I never used lambda before).
Right now, I am mainly unsure about :
> the compiler supports for the lambda
> the clarity of the syntax, simplicity of use.

Because of the 'return value feature' that you described, It looks like there is something to dig there. For that reason, let me thank you a lot. I will take some time to study it, so that I will be able to share a more precise point of view about this (given my current schedule, it can take one week).

Best regards,

Pierre Morcello

--- En date de : Lun 7.9.09, Mathias Gaunard <mathias.gaunard_at_[hidden]> a écrit :

De: Mathias Gaunard <mathias.gaunard_at_[hidden]>
Objet: Re: [boost] [Boost.Breakable] Any interest in a Boost Breakable library?
À: boost_at_[hidden]
Date: Lundi 7 Septembre 2009, 15h02

Pierre Morcello wrote:

> I propose a set of macros that allow to break anywhere. Example of use of the main macro :
>
> // do something...
> BOOST_BREAKABLE
> {
>     if (test1)
>     {
>           break;
>     }
>     if (test2)
>
>     {
>
>           break;
>
>     }
>
>
>     std::cout<<"this is never reached if test1==true or test2==true. "<<std::endl;
>     // do something...
> }
> // here the program continues ...

What about using a lambda?
[&]() -> void
{
    if(test1)
        return;

    if(test2)
        return;

    std::cout << "this is never reached if test1==true or test2==true."
              << std::endl;
    // do something...
}();

That kind of thing can also be made with macros instead of lambdas using
a similar technique to that of Boost.ScopeExit.

This also has the potential of being able to return values, which can be
pretty useful to initialize an object for example.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


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