Re: using "invariant" with structs ... possible to call when a field value is set??

2021-08-08 Thread james.p.leblanc via Digitalmars-d-learn
On Sunday, 8 August 2021 at 11:36:51 UTC, FeepingCreature wrote: You can make a field set function like so: ``` struct S { private int x_; int x(int value) { return this.x_ = value; } int x() { return this.x_; } } ``` This will then run invariants. (boilerplate can automate that for

Re: using "invariant" with structs ... possible to call when a field value is set??

2021-08-08 Thread FeepingCreature via Digitalmars-d-learn
On Sunday, 8 August 2021 at 11:30:41 UTC, james.p.leblanc wrote: Hello, With structs, I understand that "invariant checking" is called (from dlang tour): It's called after the constructor has run and before the destructor is called. It's called before entering a member function

using "invariant" with structs ... possible to call when a field value is set??

2021-08-08 Thread james.p.leblanc via Digitalmars-d-learn
Hello, With structs, I understand that "invariant checking" is called (from dlang tour): It's called after the constructor has run and before the destructor is called. It's called before entering a member function invariant() is called after exiting a member function. But, is