Ah, fair enough.
On 02.06.19 04:22, David Zhang wrote:
On Saturday, 1 June 2019 at 13:00:50 UTC, ag0aep6g wrote:
How is setting/replacing different from modifying?
e.g.:
S s;
this() { s = ...; }
update(S s) { this.s = s; }
mod(int i) { s.i = i; } // illegal
Kinda like how strings can
On Saturday, June 1, 2019 8:23:58 PM MDT David Zhang via Digitalmars-d-learn
wrote:
> On Saturday, 1 June 2019 at 16:30:12 UTC, Jonathan M Davis wrote:
> > If any member variable of a struct is const, then you can't
> > modify that member ever, and assignment isn't possible unless
> > you override
On Saturday, 1 June 2019 at 13:00:50 UTC, ag0aep6g wrote:
How is setting/replacing different from modifying?
e.g.:
S s;
this() { s = ...; }
update(S s) { this.s = s; }
mod(int i) { s.i = i; } // illegal
Kinda like how strings can be copied and assigned to, but not
modifie
On Saturday, 1 June 2019 at 16:30:12 UTC, Jonathan M Davis wrote:
If any member variable of a struct is const, then you can't
modify that member ever, and assignment isn't possible unless
you override opAssign so that it overwrites only the mutable
members. It's very rare that it makes sense to
On Saturday, June 1, 2019 6:51:08 AM MDT David Zhang via Digitalmars-d-learn
wrote:
> Say I have a struct `S`:
>
> struct S {
> /*const*/ char* pointer;
> ... other members ...
>
> this(/*const*/ char* p, ... others ...) {
> pointer = p;
>
On 01.06.19 14:51, David Zhang wrote:
struct S {
/*const*/ char* pointer;
... other members ...
this(/*const*/ char* p, ... others ...) {
pointer = p;
...
}
}
What I want, is to be able to use `S` in other data structures w
01.06.2019 15:55, drug пишет:
Is there a type-safe way to do this? If this were a class, I'd try
std.typecons.Rebindable.
Ah, sorry))
01.06.2019 15:51, David Zhang пишет:
Say I have a struct `S`:
struct S {
/*const*/ char* pointer;
... other members ...
this(/*const*/ char* p, ... others ...) {
pointer = p;
...
}
}
What I want, is to be able to use `S` i