> Joel de Guzman <joel@boost-consulting.com> on Thu, 26 Jul 2007 06:59:46 +0800
> > - bind expression with tuple becomes a nightmare
>
> Why? Ah access to the members?


It's a nightmare indeed. I'd say boost::get is not bindable at all.

typedef tuple<int, double> two;
vector<two> src;
vector<int> dst;

// ouch
const int & (*get_first)(const cons<two::head_type,
                            two::tail_type> &) = get<0>;

transform(src.begin(), src.end(), dst.begin(), get_first);

Would not it be cool to write something like this instead?

transform(src.begin(), src.end(), dst.begin(), get<0>());

And it's not hard to implement it.

namespace boost {
namespace tuples
{
    template <int N>
    struct getter
    {
        template <class HT, class TT>
        typename access_traits<
            typename element<N, cons<HT, TT> >::type
        >::non_const_type
        operator()(cons<HT, TT> & c) const
        {
            return get<N>(c);
        }

        template <class HT, class TT>
        typename access_traits<
            typename element<N, cons<HT, TT> >::type
        >::const_type
        operator()(const cons<HT, TT> & c) const
        {
            return get<N>(c);
        }
    };
}

template <int N>
tuples::getter<N> get()
{
    return tuples::getter<N>();
}
}

Does fusion have something like this?

Regards,
Roman Perepelitsa

Deutsche Bank Moscow
+7 (495) 660-74-08

---

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.