digitalmars.D.bugs - [Issue 3881] New: Structs as template arguments
- d-bugmail puremagic.com (29/29) Mar 05 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3881
- d-bugmail puremagic.com (16/16) Mar 05 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3881
- d-bugmail puremagic.com (12/12) Jul 30 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3881
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 puremagic.com ReportedBy: bearophile_hugs eml.cc 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: -------
Mar 05 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3881 Created an attachment (id=582) A possible example This attach shows a small program (that computes the N Queens at compile time) that I think may show the consequence of not being able to pass a struct to a template. I am not sure that's the cause. At the top of the program there is a constant named 'Bug', that is currently false. If you set it to true the program prints the wrong value 0 instead of 92. If the cause of the problem is not the alias of the Mark template, then I think it can be a compiler bug (or maybe just a bug of the code that I don't understand). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 05 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3881 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au This seems to be a request to allow structs as template value parameters. That's a major feature request. I suspect (haven't checked) that the test case is an unrelated compiler bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 30 2010