Why is it best to use Expects () to express prerequisites in C++
This article mainly explains why it is best to use Expects () to express the prerequisite in C++. The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Now please follow the editor's train of thought slowly and deeply, together to study and learn why it is best to use Expects () to express the prerequisite in C++.
I.6: Prefer Expects () for expressing preconditions expression prerequisite is better to use Expects ()
Reason (reason)
To make it clear that the condition is a precondition and to enable tool use.
This makes it more clear that the condition is a prerequisite and makes it available to the tool.
Example (sample)
Int area (int height, int width) {Expects (height > 0 & & width > 0); / / good if (height