function pointer bug?

Solomon E via Digitalmars-d digitalmars-d at puremagic.com
Mon Oct 27 09:08:24 PDT 2014


It works after I added 'static' to the declaration of 'invoke()' 
(and import std.stdio, std.traits.)

I fiddled around with it for hours before I tried 'static' there, 
because I've only been studying D for a week, so only about half 
of this code and the error messages made any sense to me when I 
started on it.

Once it started passing all the tests, I still didn't quite get 
how it all worked, because of suspecting there was a typo in the 
code between writing TestClass and testClass. So I tested whether 
specific instances are called (instead of maybe just the first 
one constructed) by adding a static counter to TestClass, and 
storage of the counter by each instance. It looks all right.



More information about the Digitalmars-d mailing list