Re: How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:45:19 UTC, Paul Backus wrote: On Tuesday, 19 January 2021 at 22:38:41 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:36:47 UTC, Paul Backus wrote: On Tuesday, 19 January 2021 at 22:34:04 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul

Re: How can I check to see if template type is an array?

2021-01-19 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:38:41 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:36:47 UTC, Paul Backus wrote: On Tuesday, 19 January 2021 at 22:34:04 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul Backus wrote: You've almost got it. The correct syntax is `is(T ==

Re: How can I check to see if template type is an array?

2021-01-19 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:34:04 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul Backus wrote: You've almost got it. The correct syntax is `is(T == U[], U)`. You can read it as "there exists some type U such that T == U[]". Thanks! Do I need to specify U in the

Re: How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:36:47 UTC, Paul Backus wrote: On Tuesday, 19 January 2021 at 22:34:04 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul Backus wrote: You've almost got it. The correct syntax is `is(T == U[], U)`. You can read it as "there exists some type U

Re: How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul Backus wrote: You've almost got it. The correct syntax is `is(T == U[], U)`. You can read it as "there exists some type U such that T == U[]". Thanks! Do I need to specify U in the template function?

Re: How can I check to see if template type is an array?

2021-01-19 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:26:52 UTC, Tim wrote: Hi all, I need to be able to check in a template whether the type given is an array type so that I can do some different logic. How can I do this? I would have thought that if(is(T == [])) would work, but no. Thanks in advance

Re: How can I check to see if template type is an array?

2021-01-19 Thread Dennis via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:26:52 UTC, Tim wrote: I need to be able to check in a template whether the type given is an array type so that I can do some different logic. How can I do this? `if(is(T == E[], E))` or `isDynamicArray!T` is you `import std.traits;`

How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
Hi all, I need to be able to check in a template whether the type given is an array type so that I can do some different logic. How can I do this? I would have thought that if(is(T == [])) would work, but no. Thanks in advance