D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4326 - struct invariants documentation
Summary: struct invariants documentation
Status: RESOLVED DUPLICATE of issue 3578
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-15 18:13 UTC by bearophile_hugs
Modified: 2015-06-09 05:12 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-06-15 18:13:44 UTC
I'd like D docs to state that invariants can be used inside structs too (so putting the explanation of invariants in this page is bad: http://www.digitalmars.com/d/2.0/class.html#Invariant ).

The documentation about struct invariants also needs to exaplain that the assert() syntax can't be used to call struct invariants (as it is possible with class references):


struct Foo {
    int x;
    invariant() { assert(x == 1); }
}
void main() {
    Foo f;
    assert(f); //  Error: expression f of type Foo does not have a boolean value
}
Comment 1 Leandro Lucarella 2010-06-21 17:44:13 UTC
I think this is a duplicate of bug 3578, please check if there is something missing in that bug and add it as a comment. Since both bugs are so similar I don't see a point on having both open so I'm marking it as duplicate.

Please, feel free to correct me if I'm wrong.

*** This issue has been marked as a duplicate of issue 3578 ***