On Wednesday, 12 June 2024 at 20:31:34 UTC, Vinod K Chandran wrote:
On Wednesday, 12 June 2024 at 18:57:41 UTC, bachmeier wrote:

Try `foo[10] = 1.5` and `foo.ptr[10] = 1.5`. The first correctly throws an out of bounds error. The second gives `Segmentation fault (core dumped)`.

We can use it like this, i think.
```
struct Foo {
  double * ptr;
  uint capacity;
  uint legnth;
  alias data this;

}
```
And then we use an index, we can perform a bound check.
I am not sure but I hope this will work.

Yes, you can do that, but then you're replicating what you get for free by taking a slice. You'd have to write your own opIndex, opSlice, etc., and I don't think there's any performance benefit from doing so.

Reply via email to