www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Is SIMD template

reply Manu <turkeyman gmail.com> writes:
--00235429d6d84ccb2f04b7369db7
Content-Type: text/plain; charset=UTF-8

So I've been fiddling, but I can't work it out.
Trying to make something like isStaticArray to match a vector...

template isVector(T : __vector(U[N]), U, size_t N) { enum bool isVector =
true; }
template isVector(T) { enum bool isVector = false; }

Complains:
test.d:122: Error: Integer constant expression expected instead of N
test.d:122: Error: size of type U is not known
test.d:122: Error: base type of __vector must be a 16 byte static array,
not U[N]

A size_t template arg should be an integer constant expression, and
consequently, the size of U should be known... Bug?

--00235429d6d84ccb2f04b7369db7
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

So I&#39;ve been fiddling, but I can&#39;t work it out.<div>Trying to make =
something like isStaticArray to match a vector...</div><div><br></div><div>=
<div><font face=3D"&#39;courier new&#39;, monospace"><span class=3D"Apple-t=
ab-span" style=3D"white-space:pre">	</span>template isVector(T : __vector(U=
[N]), U, size_t N) { enum bool isVector =3D true; }</font></div>
<div><font face=3D"&#39;courier new&#39;, monospace"><span class=3D"Apple-t=
ab-span" style=3D"white-space:pre">	</span>template isVector(T) { enum bool=
 isVector =3D false; }</font></div></div><div><br></div><div>Complains:</di=
v><div>
<div>test.d:122: Error: Integer constant expression expected instead of N</=
div><div>test.d:122: Error: size of type U is not known</div><div>test.d:12=
2: Error: base type of __vector must be a 16 byte static array, not U[N]</d=
iv>
</div><div><br></div><div>A size_t template arg should be an integer consta=
nt expression, and consequently, the size of U should be known...=C2=A0Bug?=
</div>

--00235429d6d84ccb2f04b7369db7--
Jan 23 2012
next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 1/23/2012 10:58 AM, Manu wrote:
 So I've been fiddling, but I can't work it out.
 Trying to make something like isStaticArray to match a vector...

 template isVector(T : __vector(U[N]), U, size_t N) { enum bool isVector =
true; }
 template isVector(T) { enum bool isVector = false; }

 Complains:
 test.d:122: Error: Integer constant expression expected instead of N
 test.d:122: Error: size of type U is not known
 test.d:122: Error: base type of __vector must be a 16 byte static array, not
U[N]

 A size_t template arg should be an integer constant expression, and
 consequently, the size of U should be known... Bug?

Code would have to be added to the compiler to make that work. In the meantime, you can simply enumerate the supported aliases for vector types.
Jan 23 2012
prev sibling next sibling parent Manu <turkeyman gmail.com> writes:
--20cf3005dee2df735d04b7376864
Content-Type: text/plain; charset=UTF-8

On 23 January 2012 21:31, Walter Bright <newshound2 digitalmars.com> wrote:

 On 1/23/2012 10:58 AM, Manu wrote:

 So I've been fiddling, but I can't work it out.
 Trying to make something like isStaticArray to match a vector...

 template isVector(T : __vector(U[N]), U, size_t N) { enum bool isVector =
 true; }
 template isVector(T) { enum bool isVector = false; }

 Complains:
 test.d:122: Error: Integer constant expression expected instead of N
 test.d:122: Error: size of type U is not known
 test.d:122: Error: base type of __vector must be a 16 byte static array,
 not U[N]

 A size_t template arg should be an integer constant expression, and
 consequently, the size of U should be known... Bug?

Code would have to be added to the compiler to make that work. In the meantime, you can simply enumerate the supported aliases for vector types.

Ah, of course! Deeer, I didn't think of that! :P --20cf3005dee2df735d04b7376864 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On 23 January 2012 21:31, Walter Bright <span di= r=3D"ltr">&lt;<a href=3D"mailto:newshound2 digitalmars.com">newshound2 digi= talmars.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" styl= e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <div class=3D"HOEnZb"><div class=3D"h5">On 1/23/2012 10:58 AM, Manu wrote:<= br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> So I&#39;ve been fiddling, but I can&#39;t work it out.<br> Trying to make something like isStaticArray to match a vector...<br> <br> template isVector(T : __vector(U[N]), U, size_t N) { enum bool isVector =3D= true; }<br> template isVector(T) { enum bool isVector =3D false; }<br> <br> Complains:<br> test.d:122: Error: Integer constant expression expected instead of N<br> test.d:122: Error: size of type U is not known<br> test.d:122: Error: base type of __vector must be a 16 byte static array, no= t U[N]<br> <br> A size_t template arg should be an integer constant expression, and<br> consequently, the size of U should be known... Bug?<br> </blockquote> <br></div></div> Code would have to be added to the compiler to make that work. In the meant= ime, you can simply enumerate the supported aliases for vector types.<br> </blockquote></div><br><div>Ah, of course!</div><div>Deeer, I didn&#39;t th= ink of that! :P</div> --20cf3005dee2df735d04b7376864--
Jan 23 2012
prev sibling parent Manu <turkeyman gmail.com> writes:
--00235433297e64c60f04b73774fb
Content-Type: text/plain; charset=UTF-8

On 23 January 2012 21:55, Manu <turkeyman gmail.com> wrote:

 On 23 January 2012 21:31, Walter Bright <newshound2 digitalmars.com>wrote:

 On 1/23/2012 10:58 AM, Manu wrote:

 So I've been fiddling, but I can't work it out.
 Trying to make something like isStaticArray to match a vector...

 template isVector(T : __vector(U[N]), U, size_t N) { enum bool isVector
 = true; }
 template isVector(T) { enum bool isVector = false; }

 Complains:
 test.d:122: Error: Integer constant expression expected instead of N
 test.d:122: Error: size of type U is not known
 test.d:122: Error: base type of __vector must be a 16 byte static array,
 not U[N]

 A size_t template arg should be an integer constant expression, and
 consequently, the size of U should be known... Bug?

Code would have to be added to the compiler to make that work. In the meantime, you can simply enumerate the supported aliases for vector types.

Ah, of course! Deeer, I didn't think of that! :P

... I guess I'll need to do this one the same way: template VectorType(T : __vector(T[N]), size_t N) { alias T VectorType; } --00235433297e64c60f04b73774fb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On 23 January 2012 21:55, Manu <span dir=3D"ltr"=
&lt;<a href=3D"mailto:turkeyman gmail.com">turkeyman gmail.com</a>&gt;</sp=

border-left:1px #ccc solid;padding-left:1ex"> <div class=3D"HOEnZb"><div class=3D"h5"><div class=3D"gmail_quote">On 23 Ja= nuary 2012 21:31, Walter Bright <span dir=3D"ltr">&lt;<a href=3D"mailto:new= shound2 digitalmars.com" target=3D"_blank">newshound2 digitalmars.com</a>&g= t;</span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> <div><div>On 1/23/2012 10:58 AM, Manu wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> So I&#39;ve been fiddling, but I can&#39;t work it out.<br> Trying to make something like isStaticArray to match a vector...<br> <br> template isVector(T : __vector(U[N]), U, size_t N) { enum bool isVector =3D= true; }<br> template isVector(T) { enum bool isVector =3D false; }<br> <br> Complains:<br> test.d:122: Error: Integer constant expression expected instead of N<br> test.d:122: Error: size of type U is not known<br> test.d:122: Error: base type of __vector must be a 16 byte static array, no= t U[N]<br> <br> A size_t template arg should be an integer constant expression, and<br> consequently, the size of U should be known... Bug?<br> </blockquote> <br></div></div> Code would have to be added to the compiler to make that work. In the meant= ime, you can simply enumerate the supported aliases for vector types.<br> </blockquote></div><br></div></div><div>Ah, of course!</div><div>Deeer, I d= idn&#39;t think of that! :P</div> </blockquote></div><br><div>... I guess I&#39;ll need to do this one the sa= me way:</div><div>template VectorType(T : __vector(T[N]), size_t N) { alias= T VectorType; }</div> --00235433297e64c60f04b73774fb--
Jan 23 2012