mirror of
https://github.com/boostorg/contract.git
synced 2026-01-27 06:42:20 +00:00
finished updating docs up to tutorial section
This commit is contained in:
21
example/features/function_comments.cpp
Normal file
21
example/features/function_comments.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
#include <limits>
|
||||
#include <cassert>
|
||||
|
||||
//[no_contracts
|
||||
int inc(int& x)
|
||||
// Precondition: x < std::numeric_limits<int>::max()
|
||||
// Postcondition: x == oldof(x) + 1
|
||||
// result == oldof(x)
|
||||
{
|
||||
return x++;
|
||||
}
|
||||
//]
|
||||
|
||||
int main() {
|
||||
int x = std::numeric_limits<int>::max() - 1;
|
||||
assert(inc(x) == std::numeric_limits<int>::max() - 1);
|
||||
assert(x == std::numeric_limits<int>::max());
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user