D's type classes pattern ?

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 24 14:45:14 PDT 2015


On 03/24/2015 09:56 AM, matovitch wrote:

 > just to be clear :
 >
 > void Bar(T : Foo)(T t){
 > }

That means "if T can implicitly be converted to Foo".

 >
 > is the same as
 >
 > void Bar(T)(T t) if (is(T == Foo)){
 > }

That means "if T is exactly Foo".

 > and it is checked only at compile time ?

Yes to both.

Ali



More information about the Digitalmars-d-learn mailing list