Boost logo

Boost :

From: Zach Laine (whatwasthataddress_at_[hidden])
Date: 2007-08-22 10:19:17


On 8/21/07, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> So that
>
> int BOOST_LOCAL_FUNCTION(name, (i)(j), (int x)(int y)) {
> //body here
> } BOOST_LOCAL_FUNCTION_END
>
> expands to
>
> int result_tag;
> typedef BOOST_TYPEOF(result_tag) result_type;
> typedef BOOST_TYPEOF(i) type_0;
> typedef BOOST_TYPEOF(j) type_1;
> typedef boost::tuple<type_0, type_1> tuple_type;
> typedef local_function<tuple_type, result_type(tuple_type, int x, int
> y)> function_type;
> function_type name(make_tuple(i, j));
> {
> function_type* function_ptr = &name;
> struct body {
> result_type impl(tuple_type& args, int x, int y) {
> type_0& i = boost::get<0>(args);
> type_1 j = boost::get<1>(args);
> {
> //body here
> }
> }
> };
> function_ptr->f = &body::impl;
> }

This requires that result_tag be default constructible. I think you
want this instead:

int *result_tag;
typedef BOOST_TYPEOF(*result_tag) result_type;
...

Zach Laine


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