Boost logo

Boost :

From: Peder Holt (peder.holt_at_[hidden])
Date: 2007-08-22 03:20:03

I vote to accept BOOST_SCOPE_EXIT.

The library complements scope guard in the same way as BOOST_FOREACH
complements std::for_each. Both of them has a place, and it depends on
the users preferences what they will use. I prefer BOOST_SCOPE_EXIT.

I would wish for a syntax more in line with BOOST_FOREACH (omitting
the BOOST_SCOPE_EXIT_END, but the best I've been able to come up with
{BOOST_SCOPE_EXIT( (commit)(m_persons) )

With the leading open clause, this is not exactly an improvement...

I too miss the BOOST_LOCAL_FUNCTION_DEF macro. This should be a part
of the library before it is included in boost.

One possible implementation is:

int i=5;
int j=4;
int BOOST_LOCAL_FUNCTION_DEF(name,(i)(j))(int x,int y)
   return i+j;


which expands to:
    int i=5;
    int j=4;
    int (*function_ref)()=0;
    typedef BOOST_TYPEOF(i) type_0;
    typedef BOOST_TYPEOF(j) type_1;
    typedef BOOST_TYPEOF(function_ref()) return_type_1;
    struct name_impl {
        type_0& i;
        type_1& j;
        name_impl(type_0& i_,type_1& j_) : i(i_),j(j_) {}
        return_type_1 operator()(int x,int y)
            return i+j;
    } name(i,j);


When it comes to handle references or copies of arguments, I think the
following can be made to work:
int BOOST_LOCAL_FUNCTION_DEF(name,ref(i)const_ref(j)(k))(int x,int y)
If not, the following can be made to work by using BOOST_PP_IS_UNARY.
( (const&)(i) ) ( j ), but this is starting to look like lisp.


Boost list run by bdawes at, gregod at, cpdaniel at, john at