Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-04-27 07:51:29


"Giovanni P. Deretta" <lordshoo_at_[hidden]> writes:

> Hi,
>
> I have been using a small extension to the tuple library 'get' function,
> that I have found very handy. It allows the extraction of an element of
> a tuple by specifying its type instead of the index.
> Example:
>
> given the tuple boost::tuple<type1, type2, type3>
>
> get<type1> returns the first element of the tuple of that type.
>
> This allows one to write more self describing code: you don't need to
> look up the tuple element type when you find an indexed get function
> buried deep inside some code.
> This is especially useful with nested tuples where for example
> 'get<3>(get<5>(get<0>(my_tuple)))' looks more like line noise than real
> code :).

You might look at c:/boost/boost/python/detail/tuple_extract.hpp

HTH,

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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