www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 688] New: Implicit function template match doesn't work for classes

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=688

           Summary: Implicit function template match doesn't work for
                    classes
           Product: D
           Version: 0.177
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: wbaxter gmail.com


IFTI works fine for structs in the case below, but doesn't work for classes.
Here's the code:

-----
// With DMD 0.177
// Error:
// template xxx.bar_class(T) does not match any template declaration
// template xxx.bar_class(T) cannot deduce template function from argument 
//         types (FooClass,FooClass)

class FooClass(T) {  T data; }

struct FooStruct(T) {  T data;  }

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

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

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
}


-- 
Dec 13 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=688


wbaxter gmail.com changed:

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




------- Comment #1 from wbaxter 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
}


-- 
Dec 17 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=688


wbaxter gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from wbaxter gmail.com  2006-12-24 00:27 -------
Confirmed fixed in DMD 0.178


-- 
Dec 23 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=688





------- Comment #3 from bugzilla digitalmars.com  2006-12-27 02:05 -------
Fixed DMD 0.178


-- 
Dec 27 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=688





------- Comment #4 from thomas-dloop kuehne.cn  2006-12-30 09:49 -------
Added to DStress as
http://dstress.kuehne.cn/compile/t/template_53_A.d
http://dstress.kuehne.cn/compile/t/template_53_B.d
http://dstress.kuehne.cn/compile/t/template_53_C.d
http://dstress.kuehne.cn/compile/t/template_53_D.d


-- 
Dec 30 2006