August 18, 2021

On Tuesday, 17 August 2021 at 14:40:20 UTC, Ferhat Kurtulmuş wrote:

>

[snip]

Very informative, thanks. My code is lying here1. I want my struct to accept 2d static arrays, random access ranges, and "std.container.Array". I could achieve it with its present form, and I will probably slightly modify it based on your comments.

If it would only accept dynamic arrays, you could use something like below

import std.traits: isDynamicArray;

template DynamicArrayOf(T : U[], U)
    if (isDynamicArray!T)
{
    alias DynamicArrayOf = U;
}

struct Point {}

void main()
{
    static assert(is(DynamicArrayOf!(int[]) == int));
    static assert(is(DynamicArrayOf!(Point[]) == Point));
}
August 19, 2021

On Tuesday, 17 August 2021 at 12:33:03 UTC, Ferhat Kurtulmuş wrote:

>

On Tuesday, 17 August 2021 at 12:26:36 UTC, jfondren wrote:

>

On Tuesday, 17 August 2021 at 12:21:31 UTC, Ferhat Kurtulmuş wrote:

>

[...]

This one's not in std.traits:

import std.range : ElementType;

struct Point { int x, y; }

unittest {
    Point[] points;
    assert(is(ElementType!(typeof(points)) == Point));
}

Hey, thank you again but, I don't want an instance of Point[] I need:

alias T = Point[];

alias ElementOfPointSlice = .... // element type of T

alias T = Point[];

unittest {
     Point[] points;
     assert(is(ElementType!(typeof(points)) == Point));
 }
August 19, 2021

On Thursday, 19 August 2021 at 03:29:03 UTC, Jesse Phillips wrote:

>

On Tuesday, 17 August 2021 at 12:33:03 UTC, Ferhat Kurtulmuş wrote:

>

On Tuesday, 17 August 2021 at 12:26:36 UTC, jfondren wrote:

>

On Tuesday, 17 August 2021 at 12:21:31 UTC, Ferhat Kurtulmuş wrote:

>

[...]

This one's not in std.traits:

import std.range : ElementType;

struct Point { int x, y; }

unittest {
    Point[] points;
    assert(is(ElementType!(typeof(points)) == Point));
}

Hey, thank you again but, I don't want an instance of Point[] I need:

alias T = Point[];

alias ElementOfPointSlice = .... // element type of T

Sorry last post was not complete. Not tested.

```
 alias T = Point[];
alias ElementOfPointSlice = ElementType!(T);

 unittest {
     assert(is(ElementOfPointSlice == Point));
  }
```
August 19, 2021

On Thursday, 19 August 2021 at 03:32:47 UTC, Jesse Phillips wrote:

>

On Thursday, 19 August 2021 at 03:29:03 UTC, Jesse Phillips wrote:

>

On Tuesday, 17 August 2021 at 12:33:03 UTC, Ferhat Kurtulmuş wrote:

>

On Tuesday, 17 August 2021 at 12:26:36 UTC, jfondren wrote:

>

On Tuesday, 17 August 2021 at 12:21:31 UTC, Ferhat Kurtulmuş wrote:

>

[...]

This one's not in std.traits:

import std.range : ElementType;

struct Point { int x, y; }

unittest {
    Point[] points;
    assert(is(ElementType!(typeof(points)) == Point));
}

Hey, thank you again but, I don't want an instance of Point[] I need:

alias T = Point[];

alias ElementOfPointSlice = .... // element type of T

Sorry last post was not complete. Not tested.

```
 alias T = Point[];
alias ElementOfPointSlice = ElementType!(T);

 unittest {
     assert(is(ElementOfPointSlice == Point));
  }
```

so, what's the problem? This passes tests:

import std.range : ElementType;

struct Point { int x, y; }
alias T = Point[];
alias ElementOfPointSlice = ElementType!(T);

unittest {
    assert(is(ElementOfPointSlice == Point));
}
August 21, 2021

On Thursday, 19 August 2021 at 04:03:31 UTC, jfondren wrote:

>

On Thursday, 19 August 2021 at 03:32:47 UTC, Jesse Phillips wrote:

> >

On Tuesday, 17 August 2021 at 12:33:03 UTC, Ferhat Kurtulmuş wrote:

>

Hey, thank you again but, I don't want an instance of Point[] I need:

alias T = Point[];

alias ElementOfPointSlice = .... // element type of T

so, what's the problem? This passes tests:

import std.range : ElementType;

struct Point { int x, y; }
alias T = Point[];
alias ElementOfPointSlice = ElementType!(T);

unittest {
    assert(is(ElementOfPointSlice == Point));
}

No issue just trying to give Ferhat a final answer to his question.

August 23, 2021

On Saturday, 21 August 2021 at 02:59:39 UTC, Jesse Phillips wrote:

>

On Thursday, 19 August 2021 at 04:03:31 UTC, jfondren wrote:

>

On Thursday, 19 August 2021 at 03:32:47 UTC, Jesse Phillips wrote:

> >

On Tuesday, 17 August 2021 at 12:33:03 UTC, Ferhat Kurtulmuş wrote:

>

Hey, thank you again but, I don't want an instance of Point[] I need:

alias T = Point[];

alias ElementOfPointSlice = .... // element type of T

so, what's the problem? This passes tests:

import std.range : ElementType;

struct Point { int x, y; }
alias T = Point[];
alias ElementOfPointSlice = ElementType!(T);

unittest {
    assert(is(ElementOfPointSlice == Point));
}
>

No issue just trying to give Ferhat a final answer to his question.

Thank you. I appreciate it.

1 2
Next ›   Last »