bad_any_cast.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright Antony Polukhin, 2020-2025.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. // See http://www.boost.org/libs/any for Documentation.
  7. #ifndef BOOST_ANYS_BAD_ANY_CAST_HPP_INCLUDED
  8. #define BOOST_ANYS_BAD_ANY_CAST_HPP_INCLUDED
  9. #include <boost/any/detail/config.hpp>
  10. #if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
  11. #ifndef BOOST_ANY_INTERFACE_UNIT
  12. #include <boost/config.hpp>
  13. #ifdef BOOST_HAS_PRAGMA_ONCE
  14. # pragma once
  15. #endif
  16. #ifndef BOOST_NO_RTTI
  17. #include <typeinfo>
  18. #endif
  19. #include <stdexcept>
  20. #endif // #ifndef BOOST_ANY_INTERFACE_UNIT
  21. namespace boost {
  22. BOOST_ANY_BEGIN_MODULE_EXPORT
  23. /// The exception thrown in the event of a failed boost::any_cast of
  24. /// an boost::any, boost::anys::basic_any or boost::anys::unique_any value.
  25. class BOOST_SYMBOL_VISIBLE bad_any_cast :
  26. #ifndef BOOST_NO_RTTI
  27. public std::bad_cast
  28. #else
  29. public std::exception
  30. #endif
  31. {
  32. public:
  33. const char * what() const BOOST_NOEXCEPT_OR_NOTHROW override
  34. {
  35. return "boost::bad_any_cast: "
  36. "failed conversion using boost::any_cast";
  37. }
  38. };
  39. BOOST_ANY_END_MODULE_EXPORT
  40. } // namespace boost
  41. #endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
  42. #endif // #ifndef BOOST_ANYS_BAD_ANY_CAST_HPP_INCLUDED