[Issue 3909] New: toDelegate handles only a tiny subset of function pointer types
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 8 23:33:43 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3909
Summary: toDelegate handles only a tiny subset of function
pointer types
Product: D
Version: 2.041
Platform: Other
OS/Version: Windows
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: samukha at voliacable.com
--- Comment #0 from Max Samukha <samukha at voliacable.com> 2010-03-08 23:33:42 PST ---
Current implementation of toDelegate requires parameter and return types of the
argument to be accessible from std.functional, meaning that it won't accept
most of function pointers taking or returning instances of UDTs:
----
import std.functional;
struct S
{
}
void foo(S s)
{
}
void main()
{
auto dg = &toDelegate(&foo);
}
Error: identifier 'S' is not defined
----
The cause is the mixed-in delegate type generated from the function pointer
type's stringof, which is invalid in the context of the template declaration.
A workaround is to avoid the stringof like this:
alias ParameterTypeTuple!(F) Params;
// mixed-in string:
alias <storage classes> ReturnType!(F) delegate(<storage classes> Params[0],
... <storage classes> Params[$ - 1]) Dg;
where <storage classes> are extracted from F's stringof (isRef, isOut, isLazy
may work too)
--
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