[Issue 566] Adding non-static members and functions to classes	doesn't error
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Jan 29 01:00:49 PST 2007
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=566
------- Comment #2 from kamm at incasoftware.de  2007-01-29 03:00 -------
Things seem to have changed a bit: now only the member variable is silently
made static while the member function works as a real non-static member
template.
class Foo
{
  template TBar(T)
  {
    T x;                   // Compiles, but is implicitly static
    void func(T t)   // Ok, non-static member template function
    { writefln(t); writefln(this.bar); }    
  }
  int bar = 42;
}
void main()
{
  Foo.TBar!(int).x = 2;
  Foo.TBar!(int).func(2); // error, since funcx is not static
  Foo f = new Foo;
  Foo g = new Foo;
  f.TBar!(int).func(2); // works
  f.TBar!(int).x = 10;
  g.TBar!(int).x = 20;
  writefln(f.TBar!(int).x); // prints 20
}
-- 
    
    
More information about the Digitalmars-d-bugs
mailing list