static_cv.hpp 744 B

12345678910111213141516171819202122232425262728
  1. // no #include guard
  2. // Copyright (C) 2008-2018 Lorenzo Caminiti
  3. // Distributed under the Boost Software License, Version 1.0 (see accompanying
  4. // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
  5. // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
  6. // Test error if static inv declared cv (unless PERMISSIVE #defined).
  7. #include <boost/contract/public_function.hpp>
  8. #include <boost/contract/check.hpp>
  9. struct a {
  10. void static_invariant() const volatile {}
  11. void f() {
  12. // Same for ctor and dtor (because they all use check_pre_post_inv).
  13. boost::contract::check c = boost::contract::public_function(this);
  14. }
  15. };
  16. int main() {
  17. a aa;
  18. aa.f();
  19. return 0;
  20. }