Limited member function templates?

Janice Caron caron800 at googlemail.com
Fri Nov 9 23:36:25 PST 2007


On 11/10/07, Bill Baxter <dnewsgroup at billbaxter.com> wrote:
> Member function templates have worked fine as long as I've been around.

Really? The documentation at http://digitalmars.com/d/template.html says:

<quote>
Templates cannot be used to add non-static members or functions to
classes. For example:

class Foo
{
    template TBar(T)
    {
	T xx;			// Error
	int func(T) { ... }	// Error

	static T yy;				// Ok
	static int func(T t, int y) { ... } 	// Ok
    }
}

Templates cannot be declared inside functions.
</quote>

>   The only thing you can't have is _virtual_ member function templates.
>   Is making them virtual what you are talking about?

All member functions in D are virtual (unless you explicitly use the
"final" keyword). So obviously, yes.



More information about the Digitalmars-d mailing list