
Hello I have constructed a type of STL containers and tuples in my prgogram, and even though I have a typedef for it, when I use it I often need the inner types involved. Now STL has the value_type declarations for all containers, but for tuples is there a documented way to get the type of a tuple member ? Or the type of the tuple<>::get<>() function ? Thank you, Timothy Madden

Zitat von Timothy Madden
Hello
I have constructed a type of STL containers and tuples in my prgogram, and even though I have a typedef for it, when I use it I often need the inner types involved.
Now STL has the value_type declarations for all containers, but for tuples is there a documented way to get the type of a tuple member ? Or the type of the tuple<>::get<>() function ?
http://www.boost.org/doc/libs/1_40_0/libs/tuple/doc/tuple_advanced_interface... you might want to use fusion vectors instead of tuples though.

Stefan Strasser wrote:
Zitat von Timothy Madden
: Hello
I have constructed a type of STL containers and tuples in my prgogram, and even though I have a typedef for it, when I use it I often need the inner types involved.
Now STL has the value_type declarations for all containers, but for tuples is there a documented way to get the type of a tuple member ? Or the type of the tuple<>::get<>() function ?
http://www.boost.org/doc/libs/1_40_0/libs/tuple/doc/tuple_advanced_interface...
you might want to use fusion vectors instead of tuples thoug
Thank you! Somehow I missed the 'Advanced features' link, which was exactly what I was looking for. I did not know about Fusion either, but for what I need it looks complicated. :) Anyway I find that when using tuples heavily it is actually better to define classes/structs for your data, as using t.get<idxHostname>() all the time is no better than t.hostname, and also not clearer. Timothy Madden

On Fri, Jul 2, 2010 at 1:26 PM, Timothy Madden
Anyway I find that when using tuples heavily it is actually better to define classes/structs for your data, as using t.get<idxHostname>() all the time is no better than t.hostname, and also not clearer.
This has been my experience too - that the get<N>() notation tends to obscure, and effectively introduce another unnecessary level of indirection. As I understand it, what tuples offer is that they're a building block for type sequences, which enable them to be handled generically, ie become the foundation for Boost.Fusion. - Rob.

On Fri, Jul 2, 2010 at 7:11 AM, Robert Jones
On Fri, Jul 2, 2010 at 1:26 PM, Timothy Madden
wrote: Anyway I find that when using tuples heavily it is actually better to define classes/structs for your data, as using t.get<idxHostname>() all the time is no better than t.hostname, and also not clearer.
This has been my experience too - that the get<N>() notation tends to obscure, and effectively introduce another unnecessary level of indirection. As I understand it, what tuples offer is that they're a building block for type sequences, which enable them to be handled generically, ie become the foundation for Boost.Fusion.
Do note, Boost.Fusion can turn structs/classes into tuples (Boost.Fusion.Vectors) so you can use them purely interchangably. Boost.Fusion is also very easy to use, especially if you know Boost.MPL (it is basically a runtime mixed version of Boost.MPL, very powerful, quite easy).
participants (4)
-
OvermindDL1
-
Robert Jones
-
Stefan Strasser
-
Timothy Madden