Creating a pointer array
data pulverizer
data.pulverizer at gmail.com
Wed Aug 19 21:10:00 UTC 2020
On Wednesday, 19 August 2020 at 20:09:31 UTC, bachmeier wrote:
> On Wednesday, 19 August 2020 at 13:03:54 UTC, data pulverizer
> wrote:
> Maybe I'm the only one, but I think double*[] is hideous, and
> I'd sure hate for someone not used to D to see it. Alias is
> your friend. I think this is much nicer:
>
> void main() {
> alias double* DoublePtr;
> DoublePtr[] arr;
> auto v = [1.0, 2.0, 3.0];
> auto w = [4.0, 5.0, 6.0];
> arr ~= [v.ptr, w.ptr];
> writeln(arr);
> }
I know what you mean. I'm using something like this:
```
alias P(T) = T*;
P!(double)[] arr;
```
alias is one of those awesome chameleons in D. The template
equivalent is
```
template P(T) = T*;
```
In this case I wonder if there is any difference as far as the
compiler is concerned?
More information about the Digitalmars-d-learn
mailing list