Nobody understands templates?

Chris wendlec at tcd.ie
Mon Mar 3 10:51:28 PST 2014


On Monday, 3 March 2014 at 17:24:08 UTC, Dominikus Dittes Scherkl 
wrote:
> On Monday, 3 March 2014 at 16:40:09 UTC, Chris wrote:
>> I'm always willing to use templates, but maybe in fact the use 
>> cases are limited. I have a class for html elements (that 
>> implements DOM functionality), and a class for building trees 
>> with the tags. Of course, for html tags only string as a type 
>> makes sense.
> Really?
> Did you consider that there are three different flavors of 
> "string"?
> Does your function really only deal with string?
> Or would someone need wstring or dstring?

Good point. Of course! I was thinking in an abstract way of 
"string".

>> class HTMLElement(T) if (is (T == string))
>>
>> }
>>
>> [...] I don't know [...] if I won't have to modify the 
>> template to adapt to new data types (which kinda defeats the 
>> purpose).
> Not much if the different types have common features.
> Most times it is still a big save of code to implement, even
> if the types need to be handled different in some places.

But it's no longer a template then, is it?


More information about the Digitalmars-d-learn mailing list