[Issue 12433] New: Allow forward referencing IFTI types in template argument list
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 21 11:17:59 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12433
Summary: Allow forward referencing IFTI types in template
argument list
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: thecybershadow at gmail.com
--- Comment #0 from Vladimir Panteleev <thecybershadow at gmail.com> 2014-03-21 20:17:57 EET ---
Consider this hypothetical example:
///////////////// test.d /////////////////
T[] copyArray(T=I, I)(I[] input)
{
auto result = new T[input.length];
foreach (n, ref i; input)
result[n] = i;
return result;
}
void main()
{
// copy as is
int[] r1 = copyArray([1, 2, 3]);
// copy to another type
long[] r2 = copyArray!long([1, 2, 3]);
}
//////////////////////////////////////////
There is currently no way to get this code to work, without either declaring an
overload for copyArray, or replacing T=I with T=SomeDummyType and later
checking to see if something was explicitly passed or not.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list