[Tuple] Addressing by named tag?

View: New views
4 Messages — Rating Filter:   Alert me  

[Tuple] Addressing by named tag?

by Robert Jones-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am I correct in believing that tuples have to be accessed by element index, as in

tuple.get<0>()

Multi-Index container has a really nice facility to use named (well typed really) tags in these
kind of expressions, but it seems tuples do not.

Anyone fancy adding it to tuple?

- Rob.

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: [Tuple] Addressing by named tag?

by Zeljko Vrba :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Jul 09, 2009 at 05:49:39PM +0100, Robert Jones wrote:

> Am I correct in believing that tuples have to be accessed by element index,
> as in
>
> tuple.get<0>()
>
> Multi-Index container has a really nice facility to use named (well typed
> really) tags in these
> kind of expressions, but it seems tuples do not.
>
> Anyone fancy adding it to tuple?
>
You're basically looking for fusion maps (look at the boost.fusion library).

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: [Tuple] Addressing by named tag?

by Robert Jones-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Jul 9, 2009 at 6:00 PM, Zeljko Vrba <zvrba@...> wrote:
On Thu, Jul 09, 2009 at 05:49:39PM +0100, Robert Jones wrote:
> Am I correct in believing that tuples have to be accessed by element index,
> as in
>
> tuple.get<0>()
>
> Multi-Index container has a really nice facility to use named (well typed
> really) tags in these
> kind of expressions, but it seems tuples do not.
>
> Anyone fancy adding it to tuple?
>
You're basically looking for fusion maps (look at the boost.fusion library).

Thanks Zeljko

I always find fusion "challenging", due to limited time to absorb it as much as
anything. Perhaps you could show me the way with few well crafted lines?

Thanks, Rob.

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: [Tuple] Addressing by named tag?

by Zeljko Vrba :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Jul 09, 2009 at 06:06:20PM +0100, Robert Jones wrote:
>
> Thanks Zeljko
>
> I always find fusion "challenging", due to limited time to absorb it as much
> as
> anything. Perhaps you could show me the way with few well crafted lines?
>
http://www.boost.org/doc/libs/1_39_0/libs/fusion/doc/html/fusion/quick_start.html
It's under "associative tuples".

Fusion documentation is thick, and when I found myself wanting some of fusion's
features, I ended up with the conclusion that I actually wanted a decent
statically-typed functional programming language with type inference, e.g.,
SML, instead of C++.  I've tried to used fusion in a project of mine, with
mixed results.  I *did* manage to use maps, though ;)

So, I will refrain from giving any examples, lest I mislead you.  It's a
long way of saying that 1) fusion may supersede tuples in the future, and
2) improbable that you will get the feature in the tuples library because
it already exists in fusion.

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users