current_exception_cast.hpp 969 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 UUID_7E83C166200811DE885E826156D89593
  5. #define UUID_7E83C166200811DE885E826156D89593
  6. #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  7. #pragma GCC system_header
  8. #endif
  9. #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  10. #pragma warning(push,1)
  11. #endif
  12. namespace
  13. boost
  14. {
  15. template <class E>
  16. inline
  17. E *
  18. current_exception_cast()
  19. {
  20. try
  21. {
  22. throw;
  23. }
  24. catch(
  25. E & e )
  26. {
  27. return &e;
  28. }
  29. catch(
  30. ...)
  31. {
  32. return 0;
  33. }
  34. }
  35. }
  36. #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
  37. #pragma warning(pop)
  38. #endif
  39. #endif