Boost logo

Boost Users :

From: Olaf Peter (ope-devel_at_[hidden])
Date: 2008-05-22 13:42:21


Hi,

> struct Test
> {
> typedef boost::tuple<int,char> tuple_t;
> tuple_t tup;
> enum Members { NAME, VALUE };
>
> typename boost::tuples::element<NAME, tuple_t>::type
> name()
> { return boost::get<NAME>(tup); }
> };

why not simple derive:

struct Test
   : boost::tuple<int,char>
{
       enum Members { NAME, VALUE };
};

Than you have the tuple calling syntax:

get<Test::Name>( ... )

That's what I use for reading and writing "named" tuples.

Regards,
Olaf


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net