[Issue 7897] Problem with alias template parameter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 20 11:43:48 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7897
Walter Bright <bugzilla at digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugzilla at digitalmars.com
--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> 2012-04-20 11:44:45 PDT ---
======
// register function in struct (doesn't work, won't take alias for some
reason?)
HookupEngineFunction!( d.outputDebug )( pImports );
======
This is failing to compile because outputDebug is a non-static member function
of struct Debug. This means that a 'this' pointer is required. The parameter
'alias funcptr' to HookupEngineFunction requires an argument that is a symbolic
alias. But you're supplying a runtime value, d.outputDebug, that cannot be
evaluated at compile time.
In other words, d.outputDebug would be a delegate, and delegates can only be
constructed at runtime because they consist of a pair: a 'this' pointer and the
address of the function. The 'this' pointer cannot be determined at compile
time.
If you make Debug.outputDebug a static member function, it will compile.
This is not a compiler bug.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list