[Issue 3881] New: Structs as template arguments
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 5 08:17:48 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3881
Summary: Structs as template arguments
Product: D
Version: 2.040
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2010-03-05 08:17:47 PST ---
The following D2 program produces the error:
test.d(4): Error: arithmetic/string type expected for value-parameter, not Foo
struct S { int x; }
// template IncS(alias f) { // works
template IncS(S f) { // doesn't work
enum S IncS = S(f.x + 1);
}
void main() {
enum S f1 = S(1);
enum S f2 = IncS!(f1);
}
It works replacing IncS(S f) with IncS(alias f), but I think using the struct
name is more type safe (there 'alias' is like dynamic typing at compile-time).
--
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