Boost logo

Boost :

From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2007-04-04 18:11:25


Steven Watanabe wrote:
> Alexander Nasonov <alnsn <at> yandex.ru> writes:
>
> >
> > Steven Watanabe wrote:
> > > I can make it work for msvc
> > How?
> >
>
> #include <boost/config.hpp>
> ...

I'm very impressed how you wrote it off the top of your head :->
But it's definitely too much magic. Though, it made me think of
another magic: study alloca implementations and replace a global
variable with something like

    BOOST_SCOPE_EXIT( (hello)(world) ) // line 1
    /* Expands to:
       struct args_line1 { std::string &hello, &world; } args_line1 = { hello, world };
       void** saved_args = (void**)aloca(sizeof(void*));
       *saved_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 = { *static_cast<void**>(last_alloca_result()) };
    */

The key here is get_alloca_result that returns a value returned by last
alloca call.

-- 
Alexander Nasonov
http://nasonov.blogspot.com
When you`re comfortable with someone you love, the silence is the
best. -- Britney Spears --
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