auto_pre_old_error.cpp 857 B

123456789101112131415161718192021222324252627
  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 auto error after old (for free func, but same for all contracts).
  6. #include <boost/config.hpp>
  7. // Not just __cplusplus to detect C++17 as MSVC defines it correctly sometimes.
  8. #if (defined(__cplusplus) && __cplusplus >= 201703L) || \
  9. !defined(BOOST_NO_CXX17_IF_CONSTEXPR)
  10. #error "C++17 copy elision invalidates test so forcing expected failure"
  11. #else
  12. #include <boost/contract/function.hpp>
  13. int main() {
  14. auto c = boost::contract::function() // Error (can't use auto).
  15. .precondition([] {})
  16. .old([] {})
  17. ;
  18. return 0;
  19. }
  20. #endif