Boost logo

Boost Users :

From: Frank Birbacher (bloodymir.crap_at_[hidden])
Date: 2006-01-20 20:29:14


Today I wanted to std::transform a range of tuples into a sequence of
one element. I thought I could just take the address of some
tuple::get<N> function. Maybe also specify the Tuple type as template
parameter. But from the source I figured the get function is not
designed in a way that would allow me easy access. I had to write myself
an additional function for this task (see below). Am I trying the wrong
way? Or would you fix the implementation?

template<size_t N, typename Tuple>
typename boost::tuples::element<1,Tuple>::type const&
getTupleElement(const Tuple& tuple)
        return boost::get<N>(tuple);

to do:

transform(..., ..., ..., &::getTupleElement<1,Tuple>);
        //using boost::lambda
for_each(..., ..., var(i) += bind(&::getTupleElement<1,Tuple>, _1));

I'd rather want to take the address of boost::tuple::get<N,Tuple>, but
the template parameters won't match.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at