[cxx-abi-dev] C++0x: Mangling for variadic templates
Daveed Vandevoorde
daveed at edg.com
Mon Jul 2 19:56:32 UTC 2007
On Jul 2, 2007, at 3:17 PM, Doug Gregor wrote:
> Variadic templates are a part of the latest C++0x working paper. In
> essence, variadic templates just allow one to write templates that
> accept an arbitrary number of template arguments. This is handled
> through a special type of template parameter called a "template
> parameter pack", which binds to one or more template arguments.
>
> GCC currently uses vendor extensions to mangle variadic templates, but
> since no compiler with that mangling has been released, we can easily
> standardize on something now. You can learn about variadic templates
> here:
>
> http://www.generic-programming.org/~dgregor/cpp/variadic-
> templates.html
>
> Or read the proposal here:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2080.pdf
>
> The only concern for mangling variadic templates is in mangling "pack
> expansions", which essentially provide a pattern that will be expanded
> several times, once for each argument bound to the parameter packs
> used in the expansion. There are three places where this affects the
> mangling:
>
> <type> ::= Dp <type> # pack expansion of (C++0x)
>
> That's a pack expansion of a type. It can show up in a function's
> parameter type or in a template argument list.
>
> Pack expansions can also show up to expand expression patterns in a
> template argument list:
>
> <template-arg> ::= sp <expression> # pack expansion of
> (C++0x)
I'm curious why you chose those particular codes? I'm guessing there
is a mnemonic at play (p = pack?), but I'm not sure which it is.
Daveed
> Finally, there is a sizeof...(X) operator that returns the length of a
> parameter pack X.
>
> <expression> ::= sZ <template-param>
>
> It's an <expression>, not an <operator-name>, because the argument is
> always a template parameter (type, non-type, or template).
>
> A patch for the ABI document is attached.
>
> - Doug<variadic.patch>
More information about the cxx-abi-dev
mailing list