introduction_comments.cpp 559 B

123456789101112131415161718192021222324
  1. // Copyright (C) 2008-2018 Lorenzo Caminiti
  2. // Distributed under the Boost Software License, Version 1.0 (see accompanying
  3. // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
  4. // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
  5. #include <cassert>
  6. //[introduction_comments
  7. void inc(int& x)
  8. // Precondition: x < std::numeric_limit<int>::max()
  9. // Postcondition: x == oldof(x) + 1
  10. {
  11. ++x; // Function body.
  12. }
  13. //]
  14. int main() {
  15. int x = 10;
  16. inc(x);
  17. assert(x == 11);
  18. return 0;
  19. }