Boost logo

Boost :

Subject: Re: [boost] [tuple] Functionals for tuple element access?
From: TONGARI (tongari95_at_[hidden])
Date: 2013-02-21 08:08:34

2013/2/21 Jan Hudec <bulb_at_[hidden]>

> Hello All,
> Doing some heavy template work on collections of pairs and tuples I came
> across the need for functors returning tuple and pair members. So I looked
> whether Boost has anything like that, but couldn't find any.
> Now the functors can be written using bind like:
> bind(_1, &TupleType::get<3>);
> bind(_1, &PairType::first);
> except that requires explicitly mentioning the tuple/pair type. Trying to
> use
> simply
> &boost::tuples::get<3, WHAT?!?!?>
> even failed for me as boost::tuples::get is actually a 3-argument template
> based on boost::tuples::cons, which looks like implementation detail I
> better
> not rely on. Besides bost methods involve pointer-to-{function,member},
> which
> might interfere with inlining.
> So I think it would be convenient to have functions like this somewhere in
> boost:

Phoenix actually has `at` for Fusion, you can use it. (Somewhat I can't
find the doc)
May be used like:


Also be sure to include the related Fusion file for adapting boost::tuple.

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