[Issue 540] New: Nested template member function error - "function expected before ()"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 17 05:37:26 PST 2006


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

           Summary: Nested template member function error - "function
                    expected before ()"
           Product: D
           Version: 0.174
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: wbaxter at gmail.com


A template member function with nesting confuses the compiler.  It is fine with
the equivalent construct existing outside a class.  It only breaks when you put
it inside the class.

class Foo {
    template myCast(T) {
        T myCast(U)(U val) {
            return cast(T) val;
        }
    }
}

void main() {
  Foo foo = new Foo;
  int i = foo.myCast!(int)(1.0);
} 

-->
Error: function expected before (), not 'foo dotexp template myCast(U)'


-- 




More information about the Digitalmars-d-bugs mailing list