[variadic templates]feature request: n-th element of expansion
Larry Evans
cppljevans@suddenlink.net
Fri Nov 20 00:29:00 GMT 2009
On 11/19/09 17:23, Jason Merrill wrote:
> On 11/17/2009 09:36 AM, Larry Evans wrote:
>> Could g++ provide this feature? How hard would it be to implement.
>
> It probably wouldn't be difficult to implement, but I'd want someone to
> champion the extension with the C++ committee as well. Have you asked
> Doug Gregor what he thinks?
Yes:
> Hi Doug,
>
> Your post:
>
>> http://groups.google.com/group/comp.std.c++/msg/40705c1e2a6f78f8
>
> contains:
>
>> > 3) A guaranteed non-recursive way to access elements of parameter
>> > packs
>> > template<int N, class ... V> struct get_type
>> > {
>> > typedef V@N type; // or implementation_defined<N,V...>::type -
>> > guaranteed linear
>> > };
>> > template<int N, class ... V> get_type<N,V...>::type get(V...v) {
>> > return ::implementation_defined<N>(v...);
>> > }
>>
>> This is probably the most-requested feature for variadic templates,
>> and it never it made it because we never found a good, unambiguous
>> syntax.
>>
> Could you elaborate on why it's hard to find some unambiguous syntax?
> For example, what would be wrong with the syntax:
>
>> get-nth-expansion-element:
>> expansion-pattern '...[' constant-expression ']'
> shown in the following post to gmane.comp.gcc.devel:
>
>> http://thread.gmane.org/gmane.comp.gcc.devel/110252
>
> TIA.
>
> -regards,
> Larry
>
>
>
> I assume that omitting this functionality
> was deliberate.
As noted in my quote of Doug's post to comp.std.c++, there
*might* be something ambiguous about:
expansion-pattern '...[' constant-expression ']'
I'm awaiting Doug's reply.
>
> Jason
>
More information about the Gcc
mailing list