$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Andrey Semashev (andysem_at_[hidden])
Date: 2007-04-03 18:03:46
Hello Alexander,
Wednesday, April 4, 2007, 12:16:34 AM, you wrote:
[snip]
> A global or thread-scope variable can be used to save a pointer to an
> object holding all references (hello and world in the example).
> Actually, the first version was based on that technique.
> This code demonstrates how it works under the hood:
> // Somewhere in the library
> __thread void* g_args;
>     // User code
>     BOOST_SCOPE_EXIT( (hello)(world) ) // line 1
>     /* Expands to:
>        struct args_line1 { std::string &hello, &world; } args_line1 = { hello, world };
>        g_args = &args_line1;
>        struct scope_exit_line1 {
>            void* m_args;
>            ~scope_exit() {
>                struct args_line1* p = (struct args_line1*)m_args;
>                doit(p->hello, p->world);
>             }
>             static void doit(std::string& hello, std::string& world)
>     */
>     {
>         // scope(exit) code
>     }
>     BOOST_SCOPE_EXIT_END // line 5
>     /*
>        } scope_exit_line5 = { g_args };
>     */
> Without g_args, it's not easy to know a name of args_line1 at line 5.
> Although a next instruction after writing to g_args is reading it,
> thread-safety is a problem and that's why I abandoned this approach.
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.
[snip]
-- Best regards, Andrey mailto:andysem_at_[hidden]