bad_address_cast.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // ip/bad_address_cast.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2019 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 BOOST_ASIO_IP_BAD_ADDRESS_CAST_HPP
  11. #define BOOST_ASIO_IP_BAD_ADDRESS_CAST_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <typeinfo>
  17. #include <boost/asio/detail/push_options.hpp>
  18. namespace boost {
  19. namespace asio {
  20. namespace ip {
  21. /// Thrown to indicate a failed address conversion.
  22. class bad_address_cast :
  23. #if defined(BOOST_ASIO_MSVC) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS
  24. public std::exception
  25. #else
  26. public std::bad_cast
  27. #endif
  28. {
  29. public:
  30. /// Default constructor.
  31. bad_address_cast() {}
  32. /// Destructor.
  33. virtual ~bad_address_cast() BOOST_ASIO_NOEXCEPT_OR_NOTHROW {}
  34. /// Get the message associated with the exception.
  35. virtual const char* what() const BOOST_ASIO_NOEXCEPT_OR_NOTHROW
  36. {
  37. return "bad address cast";
  38. }
  39. };
  40. } // namespace ip
  41. } // namespace asio
  42. } // namespace boost
  43. #include <boost/asio/detail/pop_options.hpp>
  44. #endif // BOOST_ASIO_IP_ADDRESS_HPP