This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Help understanding overloaded templates
- From: "Doug Gregor" <doug dot gregor at gmail dot com>
- To: "Rob Quill" <rob dot quill at gmail dot com>
- Cc: "GCC Development" <gcc at gcc dot gnu dot org>
- Date: Fri, 16 Nov 2007 14:58:23 -0500
- Subject: Re: Help understanding overloaded templates
- References: <baf6008d0711151921w1d5aa539v511b8a6b187d4375@mail.gmail.com>
On 11/15/07, Rob Quill <rob.quill@gmail.com> wrote:
> Hi,
>
> I was wondering if anyone could help me make sense of the
> more_specialized_fn() function in pt.c (line 13281).
>
> Specifically, I am trying to understand what each of the are:
>
> tree decl1 = DECL_TEMPLATE_RESULT (pat1);
This is the actual FUNCTION_DECL node that represents the function
template. It's just like another other (non-template) FUNCTION_DECL,
except that it's associated with a template and will use some of the
template parameters in its definition and declaration.
> tree targs1 = make_tree_vec (DECL_NTPARMS (pat1));
DECL_NTPARMS is the number of template parameters, so we're just
making a vector that long.
> tree tparms1 = DECL_INNERMOST_TEMPLATE_PARMS (pat1);
For member templates, this pulls out just the innermost template parameters.
> tree args1 = TYPE_ARG_TYPES (TREE_TYPE (decl1));
This is the list of function parameter types. e.g., in a function template
template<typename T>
void f(T*, int, float);
this would be a TREE_LIST containing the types T*,, int, and float.
> and how the function is supposed to deal with variadic functions in
> terms of these. That is to say, if a function is variadic, how is that
> represented in these data structures?
By "variadic" I assume you mean C-style variadic functions, e.g.,
template<typename T> void f(T x, ...);
and not the C++0x variadic templates.
The presence of an ellipsis is indicated by the last node in the
TREE_LIST being void_list_node; if there is no ellipsis, the last
parameter's TREE_CHAIN will simply be NULL_TREE.
- Doug