exceptional_ptr.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Distributed under the Boost Software License, Version 1.0. (See
  2. // accompanying file LICENSE_1_0.txt or copy at
  3. // http://www.boost.org/LICENSE_1_0.txt)
  4. // (C) Copyright 2014 Vicente J. Botet Escriba
  5. #ifndef BOOST_THREAD_EXCEPTIONAL_PTR_HPP
  6. #define BOOST_THREAD_EXCEPTIONAL_PTR_HPP
  7. #include <boost/thread/detail/move.hpp>
  8. #include <boost/exception_ptr.hpp>
  9. #include <boost/config/abi_prefix.hpp>
  10. namespace boost
  11. {
  12. struct exceptional_ptr {
  13. exception_ptr ptr_;
  14. exceptional_ptr() : ptr_() {}
  15. explicit exceptional_ptr(exception_ptr ex) : ptr_(ex) {}
  16. template <class E>
  17. explicit exceptional_ptr(BOOST_FWD_REF(E) ex) : ptr_(boost::copy_exception(boost::forward<E>(ex))) {}
  18. };
  19. template <class E>
  20. inline exceptional_ptr make_exceptional(BOOST_FWD_REF(E) ex) {
  21. return exceptional_ptr(boost::forward<E>(ex));
  22. }
  23. inline exceptional_ptr make_exceptional(exception_ptr ex)
  24. {
  25. return exceptional_ptr(ex);
  26. }
  27. inline exceptional_ptr make_exceptional()
  28. {
  29. return exceptional_ptr();
  30. }
  31. } // namespace boost
  32. #include <boost/config/abi_suffix.hpp>
  33. #endif