Alias this and std.traits.isArray

Philippe Sigaud philippe.sigaud at gmail.com
Wed Jan 9 14:55:44 PST 2013


On Wed, Jan 9, 2013 at 10:57 PM, David <d at dav1d.de> wrote:
>> Like this?
>>
>> struct MyType(Elem)
>> {
>>     Elem[] inner;
>>     alias inner this;
>> }
>>
>> void main()
>> {
>>     static assert(is(MyType!float _ : T[], T));
>> }
>>
>
> And how does that work for a static array?

For a static array, the generic type is T[n], for some T and a size_t n. So:

static assert(is(MyType!float _ : T[n], T, size_t n));


More information about the Digitalmars-d mailing list