| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
January 23, 2012 Is SIMD template | ||||
|---|---|---|---|---|
| ||||
Attachments:
| 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?
| |||
January 23, 2012 Re: Is SIMD template | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Manu | 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.
| |||
January 23, 2012 Re: Is SIMD template | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright Attachments:
| 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
| |||
January 23, 2012 Re: Is SIMD template | ||||
|---|---|---|---|---|
| ||||
Attachments:
| 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; }
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply