digitalmars.D.bugs - [Issue 9039] New: __vector() support in template type resolution
- d-bugmail puremagic.com (53/53) Nov 17 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9039
- d-bugmail puremagic.com (19/19) Nov 17 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9039
- d-bugmail puremagic.com (8/8) Nov 17 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9039
- d-bugmail puremagic.com (11/11) Nov 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9039
- d-bugmail puremagic.com (8/9) Nov 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9039
http://d.puremagic.com/issues/show_bug.cgi?id=9039 Summary: __vector() support in template type resolution Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: turkeyman gmail.com --- Comment #0 from Manu <turkeyman gmail.com> 2012-11-17 07:37:06 PST --- It would be really convenient if I could do this: template someTemplate(T : __vector(U[N]), U, size_t N) { // code... } Where T is a simd ('__vector()') type, and I could infer U and N this way. This would allow me to build a bunch of simd related templates in a sane way, and conveniently add simd awareness to existing templates in std.traits. Currently they tend to look like this (testing 'is' every possible type that matches): template isSIMD(T) { static if(is(T == double2) || is(T == float4) || is(T == long2) || is(T == ulong2) || is(T == int4) || is(T == uint4) || is(T == short8) || is(T == ushort8) || is(T == byte16) || is(T == ubyte16) || is(T == void16)) enum bool isVector = true; else enum bool isVector = false; } You'll even notice there is a bug in this code; 256bit vector types were added more recently, and this code wasn't updated... It would all work properly (and future-proof) if I could do it this way: template isSIMD(T : __vector(U[N]), U, size_t N) { enum bool isSIMD = true; } template isSIMD(T) { enum bool isSIMD = false; } And obvious extrapolations: elementType!(), numElements!(), etc. I could then also add support for SIMD types to the std.traits templates such as Signed!, Unsigned!, etc, rather trivially, and also simplify a lot of other code in the std.simd WIP. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 17 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9039 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla digitalmars.com --- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2012-11-17 13:16:08 PST --- This already works (it's in the test suite): void BaseTypeOfVector(T : __vector(T[N]), size_t N)(int i) { assert(is(T == int)); assert(N == 4); } void test7411() { BaseTypeOfVector!(__vector(int[4]))(3); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 17 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9039 --- Comment #2 from Manu <turkeyman gmail.com> 2012-11-17 15:19:13 PST --- Huzzah! :) It didn't work when I first tried it some time back. I should have tried it again! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 17 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9039 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WORKSFORME --- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2012-11-19 16:39:41 PST --- Guess we can close this, then! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 19 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9039 --- Comment #4 from Manu <turkeyman gmail.com> 2012-11-19 17:00:23 PST --- (In reply to comment #3)Guess we can close this, then!Yeah go for it. Sorry for opening a redundant ticket >_< -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 19 2012