This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Template parameter type inference algorithm
Piotr Wyderski:
>
> Dave Korn wrote:
>
>> I Am Not A Language Lawyer, but IIUIC all the procedures for resolving
>> names and overloading are clearly specified in the C++ language spec,
>> and
>> the compiler implements the standards-mandated algorithms.
>
> The specification defines only the inference rules. Their
> effective implementation (i.e. the thing I'd like to know)
> is a separate problem. :-)
For template argument deduction, g++ uses a "standard"
unification algorithm (if you've already written one for a Prolog
implementation, you should get the idea). Have a look
at unify() in cp/pt.c.
For overload resolution, the C++ standard text really does
specify an algorithm and I would include verbatim the
suggestion made by Dave Korn.
-- Gaby