Re: Manually check struct invariants

2021-03-23 Thread Q. Schroll via Digitalmars-d-learn
On Tuesday, 23 March 2021 at 23:27:54 UTC, Paul Backus wrote: On Tuesday, 23 March 2021 at 22:22:12 UTC, Q. Schroll wrote: For a class object obj, one can use assert(obj) to get its invariants checked. How to do this for structs? https://dlang.org/spec/expression.html#assert_expressions If th

Re: Manually check struct invariants

2021-03-23 Thread Ali Çehreli via Digitalmars-d-learn
On 3/23/21 4:14 PM, Imperatorn wrote:> On Tuesday, 23 March 2021 at 22:22:12 UTC, Q. Schroll wrote: >> For a class object obj, one can use assert(obj) to get its invariants >> checked. How to do this for structs? > > It's called after the constructor has run and before the destructor is > called.

Re: Manually check struct invariants

2021-03-23 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 23 March 2021 at 22:22:12 UTC, Q. Schroll wrote: For a class object obj, one can use assert(obj) to get its invariants checked. How to do this for structs? https://dlang.org/spec/expression.html#assert_expressions If the first AssignExpression is a pointer to a struct instance for

Re: Manually check struct invariants

2021-03-23 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 23 March 2021 at 22:22:12 UTC, Q. Schroll wrote: For a class object obj, one can use assert(obj) to get its invariants checked. How to do this for structs? It's called after the constructor has run and before the destructor is called. It's called before entering a member function

Manually check struct invariants

2021-03-23 Thread Q. Schroll via Digitalmars-d-learn
For a class object obj, one can use assert(obj) to get its invariants checked. How to do this for structs?