current_exception_cast.hpp 993 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
  2. //Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #ifndef BOOST_EXCEPTION_7E83C166200811DE885E826156D89593
  5. #define BOOST_EXCEPTION_7E83C166200811DE885E826156D89593
  6. #ifndef BOOST_EXCEPTION_ENABLE_WARNINGS
  7. #if __GNUC__*100+__GNUC_MINOR__>301
  8. #pragma GCC system_header
  9. #endif
  10. #ifdef __clang__
  11. #pragma clang system_header
  12. #endif
  13. #ifdef _MSC_VER
  14. #pragma warning(push,1)
  15. #endif
  16. #endif
  17. namespace
  18. boost
  19. {
  20. template <class E>
  21. inline
  22. E *
  23. current_exception_cast()
  24. {
  25. try
  26. {
  27. throw;
  28. }
  29. catch(
  30. E & e )
  31. {
  32. return &e;
  33. }
  34. catch(
  35. ...)
  36. {
  37. return 0;
  38. }
  39. }
  40. }
  41. #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  42. #pragma warning(pop)
  43. #endif
  44. #endif