pre_error.cpp 638 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. // Test destructor cannot use `.precondition(...)`.
  6. #include <boost/contract/destructor.hpp>
  7. #include <boost/contract/check.hpp>
  8. struct a {
  9. ~a() {
  10. boost::contract::check c = boost::contract::destructor(this)
  11. .precondition([] {}) // Error (no dtor func arg so never pre).
  12. ;
  13. }
  14. };
  15. int main() {
  16. a aa;
  17. return 0;
  18. }