boost_no_cxx11_exception.ipp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // (C) Copyright Beman Dawes 2009
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/config for more information.
  6. // MACRO: BOOST_NO_CXX11_HDR_EXCEPTION
  7. // TITLE: C++11 header <exception> not compatible
  8. // DESCRIPTION: The standard library does not provide a C++11 compatible version of <exception>.
  9. #include <exception>
  10. namespace boost_no_cxx11_hdr_exception {
  11. int test()
  12. {
  13. #ifdef BOOST_NO_EXCEPTIONS
  14. using std::exception_ptr;
  15. using std::current_exception;
  16. using std::rethrow_exception;
  17. return 0;
  18. #else
  19. std::exception_ptr ep;
  20. try
  21. {
  22. throw 42;
  23. }
  24. catch (...)
  25. {
  26. ep = std::current_exception();
  27. }
  28. try
  29. {
  30. std::rethrow_exception(ep);
  31. }
  32. catch (int i)
  33. {
  34. // return zero on success
  35. return i == 42 ? 0 : 1;
  36. }
  37. return 1;
  38. #endif
  39. }
  40. }