Add type/class invariants contract to Cpp2 #1021
DyXel
started this conversation in
Suggestions
Replies: 1 comment
-
I think Herb has a metafunction in mind for just this kind of use case. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Contracts already exist in Cpp2, and so do pre-conditions and post-conditions, but I would really like to be able to write my type contracts once and see the benefit on all member functions, which is exactly what invariants provide.
p2900r4 says "... the following features are intentionally not included in this proposal; however, we expect these features to be proposed post-MVP extensions at a later time ...", followed by "... The ability to express class invariants. ...", so I think its in the spirit of cppfront to start experimenting on this early.
Personally I think we can start experimenting with a new contextual keyword (
invariant
as mentioned in the paper), and see where that leads us. Thoughts?Beta Was this translation helpful? Give feedback.
All reactions