On Monday, 14 June 2021 at 17:34:00 UTC, Steven Schveighoffer
wrote:
D doesn't have head-const. So you must hide the mutable
implementation to get this to work.
You'd want to do this anyway, since you don't want to directly
use the pointer for anything like indexing (it should first
validate
I'm searching for a way to do something like this in D:
```cpp
struct MyStruct {
const size_t length;
int *const data;
MyStruct(size_t n) : length(n) {
data = new int[length];
}
}
```
This way it is mutable, but non resizeable:
```cpp
MyStruct s = MyStruct(10);
s.data[0] = 42;