class scope virtual template functions

BCS ao at pathlink.com
Thu May 29 13:10:01 PDT 2008


Reply to Walter,

> BCS wrote:
> 
>> However in highly limited cases, this is not an issue.
>> 1) the template members are enumerations (just build the whole set)
>> 2) the function has no parameters (only one version can be built)
>> 3) no general form of the template exists, only explicit
>> specializations
>> (ditto enum)
>> 4) class scope aliases of member templates are used. (instance the
>> template and stuff it in as a normal function)
> True, but now you have the issue that minor, seemingly innocuous
> changes to a template function can have dramatic changes to its
> behavior. It's a lot easier to understand "template functions are not
> virtual" than "template functions are not virtual except in these
> rather complex scenarios."
> 
> If you need virtual behavior from a template function, the best way is
> to wrap a virtual function call within it.
> 

in my case, I need this syntax

this.Templet!("foo")(arg)

to be virtual.

The use case is inside of dparse where I have template code calling template 
code.





More information about the Digitalmars-d mailing list