bad_any_cast.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright Antony Polukhin, 2020-2024.
  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/config.hpp>
  10. #ifdef BOOST_HAS_PRAGMA_ONCE
  11. # pragma once
  12. #endif
  13. #ifndef BOOST_NO_RTTI
  14. #include <typeinfo>
  15. #endif
  16. #include <stdexcept>
  17. namespace boost {
  18. /// The exception thrown in the event of a failed boost::any_cast of
  19. /// an boost::any, boost::anys::basic_any or boost::anys::unique_any value.
  20. class BOOST_SYMBOL_VISIBLE bad_any_cast :
  21. #ifndef BOOST_NO_RTTI
  22. public std::bad_cast
  23. #else
  24. public std::exception
  25. #endif
  26. {
  27. public:
  28. const char * what() const BOOST_NOEXCEPT_OR_NOTHROW override
  29. {
  30. return "boost::bad_any_cast: "
  31. "failed conversion using boost::any_cast";
  32. }
  33. };
  34. } // namespace boost
  35. #endif // #ifndef BOOST_ANYS_BAD_ANY_CAST_HPP_INCLUDED