future_error_code.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // (C) Copyright 2008-10 Anthony Williams
  2. // (C) Copyright 2011-2012,2015 Vicente J. Botet Escriba
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See
  5. // accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_THREAD_FUTURES_FUTURE_ERROR_CODE_HPP
  8. #define BOOST_THREAD_FUTURES_FUTURE_ERROR_CODE_HPP
  9. #include <boost/thread/detail/config.hpp>
  10. #include <boost/core/scoped_enum.hpp>
  11. #include <boost/system/error_code.hpp>
  12. #include <boost/type_traits/integral_constant.hpp>
  13. namespace boost
  14. {
  15. //enum class future_errc
  16. BOOST_SCOPED_ENUM_DECLARE_BEGIN(future_errc)
  17. {
  18. broken_promise = 1,
  19. future_already_retrieved,
  20. promise_already_satisfied,
  21. no_state
  22. }
  23. BOOST_SCOPED_ENUM_DECLARE_END(future_errc)
  24. namespace system
  25. {
  26. template <>
  27. struct BOOST_SYMBOL_VISIBLE is_error_code_enum< ::boost::future_errc> : public true_type {};
  28. #ifdef BOOST_NO_CXX11_SCOPED_ENUMS
  29. template <>
  30. struct BOOST_SYMBOL_VISIBLE is_error_code_enum< ::boost::future_errc::enum_type> : public true_type { };
  31. #endif
  32. } // system
  33. BOOST_THREAD_DECL
  34. const system::error_category& future_category() BOOST_NOEXCEPT;
  35. namespace system
  36. {
  37. inline
  38. error_code
  39. make_error_code(future_errc e) BOOST_NOEXCEPT
  40. {
  41. return error_code(underlying_cast<int>(e), boost::future_category());
  42. }
  43. inline
  44. error_condition
  45. make_error_condition(future_errc e) BOOST_NOEXCEPT
  46. {
  47. return error_condition(underlying_cast<int>(e), boost::future_category());
  48. }
  49. } // system
  50. } // boost
  51. #endif // header