|
Boost : |
From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2007-04-03 18:52:54
Andrey Semashev wrote:
> What if something like that:
>
> BOOST_SCOPE_EXIT // line 1
> /*
> Expands to:
> struct _scope_guard_class_line1
> {
> ~_scope_guard_class_line1()
> {
> */
> {
> // scope(exit) code
> }
> BOOST_SCOPE_EXIT_END((hello)(world)); // line 5
> /*
> Expands to:
> }
>
> std::string& hello;
> std::string& world;
> } _scope_guard_line5 = { hello, world };
> */
>
>
> While the variable list is now in the end, no ids needed at all.
I considered it too but I thought it could scare people.
So, we have
1.
BOOST_SCOPE_EXIT
{
// ...
} BOOST_SCOPE_EXIT_END( (hello)(world) )
2.
BOOST_SCOPE_EXIT(id, (hello)(world) )
{
// ...
} BOOST_SCOPE_EXIT_END(id)
3. with global variable
BOOST_SCOPE_EXIT( (hello)(world) )
{
// ...
} BOOST_SCOPE_EXIT_END
I even considered something like this in the past:
{ BOOST_SCOPE_EXIT( (hello)(world) {
// code
}} id;
It may seem strange but not to people familiar with ruby blocks:
{ |hello,world|
// code
}
-- Alexander Nasonov http://nasonov.blogspot.com Don`t knock masturbation; it`s sex with someone I love. -- Woody Allen -- This quote is generated by: /usr/pkg/bin/curl -L http://tinyurl.com/veusy \ | sed -e 's/^document\.write(.//' -e 's/.);$/ --/' \ -e 's/<[^>]*>//g' -e 's/^More quotes from //' \ | fmt | tee ~/.signature-quote
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk