current_exception_cast.hpp 660 B

12345678910111213141516171819202122232425262728293031323334
  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. namespace
  7. boost
  8. {
  9. template <class E>
  10. inline
  11. E *
  12. current_exception_cast()
  13. {
  14. try
  15. {
  16. throw;
  17. }
  18. catch(
  19. E & e )
  20. {
  21. return &e;
  22. }
  23. catch(
  24. ...)
  25. {
  26. return 0;
  27. }
  28. }
  29. }
  30. #endif