digitalmars.D.bugs - more templates (and metaprogramming a-la boost)
- Carlos Santander B. (57/57) May 20 2004 In
- J Anderson (32/90) May 20 2004 Alot of 2567 errors coming up recently. This has been broken since
- C. Sauls (5/6) May 21 2004 Try changing the template decleration to:
In http://msdn.microsoft.com/visualc/using/understanding/perf/default.aspx?pull=/library/en-us/dv_vstecha t/html/boostvc.asp, I found this piece of C++ code: template< typename T > class auto_size_example : private mpl::if_< sizeof(T) <= sizeof(double) , stack_implementation<T> , heap_implementation<T> >::type { // ... }; I thought, this can also be done in D, so I tried to. I figured this could be the way: template CT (alias cmp, T1, T2) { version (cmp) alias T1 S; else alias T2 S; class C : S { } } class C1 (T) { } class C2 (T) { } template T2 ( T ) { class C : CT!( T.size < double.size , C1!(T), C2!(T) ).C { } } void main() { T2!(int).C t; } However I get "template instance CT!(1,C1 ,C2 ) does not match any template declaration" (again, no line number, no nothing). DMD wouldn't let me write "class C : .CT..." (notice the dot before CT), so I decided to rewrite T2 as: template T2 ( T ) { alias .CT!( T.size < double.size , C1!(T), C2!(T) ).C S; class C : S { } } But then I got the horrible: "Assertion failure: 'id->dyncast() == DYNCAST_IDENTIFIER' on line 2567 in file 'mtype.c' abnormal program termination" ----------------------- Carlos Santander Bernal
May 20 2004
Alot of 2567 errors coming up recently. This has been broken since .89. It's dam annoying when your project just breaks for no good reason. Your workaround is served cold: Well I got this much working: template CT (T1, T2) //Took out the cmp - note this doesn't effect the intenal bug { class C : S { } } class C1 (T) { } class C2 (T) { } template T2 ( T ) { alias .CT CCT; //The workaround - Prevents internal error alias CCT!(C1!(T), C2!(T)).C S; class C : S { } } void main() { T2!(int).C t; Carlos Santander B. wrote:In http://msdn.microsoft.com/visualc/using/understanding/perf/default.aspx?pull=/library/en-us/dv_vstecha t/html/boostvc.asp, I found this piece of C++ code: template< typename T > class auto_size_example : private mpl::if_< sizeof(T) <= sizeof(double) , stack_implementation<T> , heap_implementation<T> >::type { // ... }; I thought, this can also be done in D, so I tried to. I figured this could be the way: template CT (alias cmp, T1, T2) { version (cmp) alias T1 S; else alias T2 S; class C : S { } } class C1 (T) { } class C2 (T) { } template T2 ( T ) { class C : CT!( T.size < double.size , C1!(T), C2!(T) ).C { } } void main() { T2!(int).C t; } However I get "template instance CT!(1,C1 ,C2 ) does not match any template declaration" (again, no line number, no nothing). DMD wouldn't let me write "class C : .CT..." (notice the dot before CT), so I decided to rewrite T2 as: template T2 ( T ) { alias .CT!( T.size < double.size , C1!(T), C2!(T) ).C S; class C : S { } } But then I got the horrible: "Assertion failure: 'id->dyncast() == DYNCAST_IDENTIFIER' on line 2567 in file 'mtype.c' abnormal program termination" ----------------------- Carlos Santander Bernal-- -Anderson: http://badmama.com.au/~anderson/
May 20 2004
template CT (alias cmp, T1, T2)Try changing the template decleration to: template CT (int cmp, T1, T2) Just a thought. -C. Sauls -Invironz
May 21 2004