error.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/url
  8. //
  9. #ifndef BOOST_URL_IMPL_ERROR_HPP
  10. #define BOOST_URL_IMPL_ERROR_HPP
  11. #include <type_traits>
  12. namespace boost {
  13. //-----------------------------------------------
  14. namespace system {
  15. template<>
  16. struct is_error_code_enum<::boost::urls::error>
  17. {
  18. static bool const value = true;
  19. };
  20. } // system
  21. //-----------------------------------------------
  22. namespace urls {
  23. namespace detail {
  24. struct BOOST_SYMBOL_VISIBLE
  25. error_cat_type
  26. : system::error_category
  27. {
  28. BOOST_URL_DECL const char* name(
  29. ) const noexcept override;
  30. BOOST_URL_DECL std::string message(
  31. int) const override;
  32. BOOST_URL_DECL char const* message(
  33. int, char*, std::size_t
  34. ) const noexcept override;
  35. BOOST_URL_DECL system::error_condition
  36. default_error_condition(
  37. int code) const noexcept override;
  38. BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept
  39. : error_category(0xbc15399d7a4ce829)
  40. {
  41. }
  42. };
  43. BOOST_URL_DECL extern
  44. error_cat_type error_cat;
  45. } // detail
  46. inline
  47. BOOST_SYSTEM_CONSTEXPR
  48. system::error_code
  49. make_error_code(
  50. error ev) noexcept
  51. {
  52. return system::error_code{
  53. static_cast<std::underlying_type<
  54. error>::type>(ev),
  55. detail::error_cat};
  56. }
  57. } // urls
  58. } // boost
  59. #endif