[Issue 688] Implicit function template match doesn't work for classes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 17 17:53:42 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=688


wbaxter at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wbaxter at gmail.com




------- Comment #1 from wbaxter at gmail.com  2006-12-17 19:53 -------
Here's another manifestation of what is probably the same bug: 
  is(Type id:specialization) doesn't work for classes either.

Here's the previous example with the is test added too:


----------
class FooClass(T) {  T data; }

struct FooStruct(T) {  T data;  }

void bar_struct(T)(FooStruct!(T) a) {}

void bar_class(T)(FooClass!(T) a) {}

template base_type(S) {
    static if ( is(S T : FooStruct!(T)) ) {
        alias T base_type;
    }
    else static if ( is(S T : FooClass!(T)) ) {
        alias T base_type;
    }
    else {
        static assert(0, "Unknown type");
    }
}

void main()
{

    auto C = new FooClass!(double);
    FooStruct!(double) S;

    bar_struct(S);  // works
    bar_class!(double)(C);  // works
    bar_class(C);   // does not work

    alias base_type!(FooStruct!(double)) sbase;//good
    alias base_type!(FooClass!(double)) cbase;//no good
}


-- 



More information about the Digitalmars-d-bugs mailing list