channel_error.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // experimental/channel_error.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef ASIO_EXPERIMENTAL_CHANNEL_ERROR_HPP
  11. #define ASIO_EXPERIMENTAL_CHANNEL_ERROR_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include "asio/error_code.hpp"
  17. #include "asio/detail/push_options.hpp"
  18. namespace asio {
  19. namespace experimental {
  20. namespace error {
  21. enum channel_errors
  22. {
  23. /// The channel was closed.
  24. channel_closed = 1,
  25. /// The channel was cancelled.
  26. channel_cancelled = 2
  27. };
  28. extern ASIO_DECL
  29. const asio::error_category& get_channel_category();
  30. static const asio::error_category&
  31. channel_category ASIO_UNUSED_VARIABLE
  32. = asio::experimental::error::get_channel_category();
  33. } // namespace error
  34. namespace channel_errc {
  35. // Simulates a scoped enum.
  36. using error::channel_closed;
  37. using error::channel_cancelled;
  38. } // namespace channel_errc
  39. } // namespace experimental
  40. } // namespace asio
  41. namespace std {
  42. template<> struct is_error_code_enum<
  43. asio::experimental::error::channel_errors>
  44. {
  45. static const bool value = true;
  46. };
  47. } // namespace std
  48. namespace asio {
  49. namespace experimental {
  50. namespace error {
  51. inline asio::error_code make_error_code(channel_errors e)
  52. {
  53. return asio::error_code(
  54. static_cast<int>(e), get_channel_category());
  55. }
  56. } // namespace error
  57. } // namespace experimental
  58. } // namespace asio
  59. #include "asio/detail/pop_options.hpp"
  60. #if defined(ASIO_HEADER_ONLY)
  61. # include "asio/experimental/impl/channel_error.ipp"
  62. #endif // defined(ASIO_HEADER_ONLY)
  63. #endif // ASIO_EXPERIMENTAL_CHANNEL_ERROR_HPP