no_exceptions_support_test.cpp 797 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // Test for no_exceptions_support.hpp
  3. //
  4. // Copyright 2019 Peter Dimov
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt
  9. //
  10. #include <boost/core/no_exceptions_support.hpp>
  11. #include <boost/core/quick_exit.hpp>
  12. #include <boost/throw_exception.hpp>
  13. #include <exception>
  14. void f()
  15. {
  16. boost::throw_exception( std::exception() );
  17. }
  18. int main()
  19. {
  20. BOOST_TRY
  21. {
  22. f();
  23. }
  24. BOOST_CATCH( std::exception const& )
  25. {
  26. return 0;
  27. }
  28. BOOST_CATCH( ... )
  29. {
  30. return 1;
  31. }
  32. BOOST_CATCH_END
  33. return 1;
  34. }
  35. #if defined(BOOST_NO_EXCEPTIONS)
  36. namespace boost
  37. {
  38. void throw_exception( std::exception const& )
  39. {
  40. boost::quick_exit( 0 );
  41. }
  42. }
  43. #endif