template condition

Timon Gehr timon.gehr at gmx.ch
Thu Sep 27 06:38:42 PDT 2012


On 09/27/2012 03:01 PM, Namespace wrote:
> Is there any difference between these two code snippets:
>
> #1:
> struct Foo(T : Object) {
>
> #2:
> struct Foo(T) if (is(T == class)) {
>
> ?
>
> I ask because I prefer option #1, but I see most often in Phobos variant
> #2.

Yes there is:

struct S{
     Object o;
     alias o this;
}

#1 accepts S, #2 does not.


More information about the Digitalmars-d-learn mailing list