This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [variadic templates]feature request: n-th element of expansion


On 11/19/09 18:28, Larry Evans wrote:
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?
[snip]
Just got an interesting reply from Doug
(parts of which I've forwarded to you).
The interesting parts include:

On 11/24/09 23:40, Doug Gregor wrote:

Could you elaborate on why it's hard to find some unambiguous syntax?

Mostly because we didn't want to get into the game of introducing more entirely new operators. "sizeof..." itself only happened because we started with sizeof(Pack...) and the C++ evolution working group found that confusing.

> 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

Seems plausible. You probably wouldn't want to make "...[" a single token, since adding tokens gets into token-pasting ickiness; rather, you'd need to do lookahead whenever you see a "..." that could, syntactically, be a get-nth-expansion-element.

From the standardese perspective, it's important to call out that the
ellipsis in a get-nth-expansion-element expands the parameter packs in
the expansion-pattern but not any parameter packs in the
constant-expression. That means that we get slicing for free:

typedef tuple<TypePack...[IndexPack]...> selected_types;

I don't think this would be hard to implement in GCC. It will be very
hard to get it into C++0x, but you might convince Jason to take it as
a GCC extension... then you'll force the rest of us to implement it
anyway :)

What about just trying it? Anything I could do to help?


-regards,
Larry


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]