Topic: variadict templates wish: get nth element for parameter pack


Author: cppljevans@gmail.com
Date: Tue, 5 May 2009 14:14:47 CST
Raw View
Boost's mpl arg template:

http://www.boost.org/doc/libs/1_39_0/libs/mpl/doc/refmanual/arg.html

is implemented using the boost /preprocessor library:

https://svn.boost.org/trac/boost/browser/trunk/boost/mpl/arg.hpp#L93

This boost/preprocessor requirement would be unnecessary if something
like the args[i] feature described on p. 8 of:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1704.pdf

were available.  Actually, what's really required is indexing into
the types instead of the values, i.e. Args[i] instead of args[i], but
that's probably just as easy to implement, I guess.

Are there any plans to make feature available soon?


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Pavel Minaev <int19h@gmail.com>
Date: Wed, 6 May 2009 11:09:09 CST
Raw View
On May 5, 1:14 pm, cppljev...@gmail.com wrote:
> Boost's mpl arg template:
>
> http://www.boost.org/doc/libs/1_39_0/libs/mpl/doc/refmanual/arg.html
>
> is implemented using the boost /preprocessor library:
>
> https://svn.boost.org/trac/boost/browser/trunk/boost/mpl/arg.hpp#L93
>
> This boost/preprocessor requirement would be unnecessary if something
> like the args[i] feature described on p. 8 of:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1704.pdf
>
> were available.  Actually, what's really required is indexing into
> the types instead of the values, i.e. Args[i] instead of args[i], but
> that's probably just as easy to implement, I guess.
>
> Are there any plans to make feature available soon?

Isn't it something that can be trivially implemented with template
metaprogramming on your own, where needed?


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: cppljevans@gmail.com
Date: Wed, 6 May 2009 16:20:29 CST
Raw View
On May 6, 12:09 pm, Pavel Minaev <int...@gmail.com> wrote:
> On May 5, 1:14 pm, cppljev...@gmail.com wrote:
>
>
>
> > Boost's mpl arg template:
>
> >http://www.boost.org/doc/libs/1_39_0/libs/mpl/doc/refmanual/arg.html
>
> > is implemented using the boost /preprocessor library:
>
> >https://svn.boost.org/trac/boost/browser/trunk/boost/mpl/arg.hpp#L93
>
> > This boost/preprocessor requirement would be unnecessary if something
> > like the args[i] feature described on p. 8 of:
>
> >http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1704.pdf
>
> > were available.  Actually, what's really required is indexing into
> > the types instead of the values, i.e. Args[i] instead of args[i], but
> > that's probably just as easy to implement, I guess.
>
> > Are there any plans to make feature available soon?
>
> Isn't it something that can be trivially implemented with template
> metaprogramming on your own, where needed?

Yes.  However, I'm concerned about the compile-time cost.
The arg template is used so extensively in boost that I was
afraid that any metaprogramming used to implement it
would be greeted with skepticism about the compile-time
cost.  Also, since the n1704 reference mentioned the feature
would be simple to implement, I was hoping it would be
implemented soon.

However, I may just go ahead and do it since, as you mention,
it would be trivial and could be replaced in the future when
the feature becomes available.  The method I'm thinking
of using could also be reused for implementing the get<I>
for tuples.  Doug hinted at how such a tuple could be
implemented here:

http://groups.google.com/group/comp.std.c++/msg/6449d909fd3d5cdc

BTW, that's where I first encountered the concept of "unpacking
patterns" mentioned in my recent response to you in the other
thread:

http://groups.google.com/group/comp.std.c++/msg/e85441c884f0ccc5

A demo of that implementation is attached to a post to the spirit
develop
list:


http://sourceforge.net/mailarchive/message.php?msg_name=gnpn19%24k07%241%40ger.gmane.org




--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]