D's limited template specialization abilities compared to C++

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat May 25 12:53:33 PDT 2013


On 5/25/13 12:27 PM, deadalnix wrote:
> Hi, I obviously don't know D that much, but I assume I do.
>
> I have this feature that I can't even show a working example that exists
> in C++. I also can't come up with any use case, but I know this is
> mandatory to have.
>
> As I assume I know D well enough, I assume I know that this is
> impossible in D, so I propose an improvement.
>
> With that improvement, a new syntax is introduced to support some new
> feature that is barely defined and it can be used in unknown situation.
>
> I also explain myself using my own made up syntax. I don't care if it
> conflict with other language construct as it is superior anyway.

A great thing about this community is it being nice and helpful to 
newcomers. (That said, I had a good chuckle - I've seen this pattern 
before.)

To the OP: you may want to look into template constraints, they're much 
easier to define and use than pattern matching in template arguments. 
Also, aliases are quite a bit more convenient and general than C++'s 
template template arguments, which run completely amok at the third 
regression:

template<template<template <class> class> class T> class C;


Andrei


More information about the Digitalmars-d mailing list