template specialization and Rebindable

vit vit at vit.vit
Sun Dec 3 16:39:16 UTC 2017


Why is template param T != B but T == Rebindable!(const(B)) when 
specialization is T : const(A)?

abstract class A{}
class B : A{}

string foo(T : const(A))(T x){
     return T.stringof;
}

void main(){
     import std.typecons : Rebindable;
     import std.stdio : writeln;

     Rebindable!(const B) b = new B;

     auto bar = foo(b);
     assert(bar == "Rebindable!(const(B))");

}


More information about the Digitalmars-d-learn mailing list