File indexing completed on 2025-01-18 09:39:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef BOOST_LEXICAL_CAST_BAD_LEXICAL_CAST_HPP
0019 #define BOOST_LEXICAL_CAST_BAD_LEXICAL_CAST_HPP
0020
0021 #include <boost/config.hpp>
0022 #ifdef BOOST_HAS_PRAGMA_ONCE
0023 # pragma once
0024 #endif
0025
0026 #include <exception>
0027 #include <typeinfo>
0028 #include <boost/throw_exception.hpp>
0029
0030 namespace boost
0031 {
0032
0033 class BOOST_SYMBOL_VISIBLE bad_lexical_cast :
0034
0035 #if defined(BOOST_MSVC) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS
0036 public std::exception
0037 #else
0038 public std::bad_cast
0039 #endif
0040 {
0041 public:
0042 bad_lexical_cast() noexcept
0043 #ifndef BOOST_NO_TYPEID
0044 : source(&typeid(void)), target(&typeid(void))
0045 #endif
0046 {}
0047
0048 const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
0049 return "bad lexical cast: "
0050 "source type value could not be interpreted as target";
0051 }
0052
0053 bad_lexical_cast(const bad_lexical_cast&) = default;
0054 bad_lexical_cast& operator=(const bad_lexical_cast&) = default;
0055
0056 #ifndef BOOST_NO_TYPEID
0057 private:
0058 #ifdef BOOST_NO_STD_TYPEINFO
0059 typedef ::type_info type_info_t;
0060 #else
0061 typedef ::std::type_info type_info_t;
0062 #endif
0063 public:
0064 bad_lexical_cast(
0065 const type_info_t &source_type_arg,
0066 const type_info_t &target_type_arg) noexcept
0067 : source(&source_type_arg), target(&target_type_arg)
0068 {}
0069
0070 const type_info_t &source_type() const noexcept {
0071 return *source;
0072 }
0073
0074 const type_info_t &target_type() const noexcept {
0075 return *target;
0076 }
0077
0078 private:
0079 const type_info_t *source;
0080 const type_info_t *target;
0081 #endif
0082 };
0083
0084 namespace conversion { namespace detail {
0085 #ifdef BOOST_NO_TYPEID
0086 template <class S, class T>
0087 inline void throw_bad_cast() {
0088 boost::throw_exception(bad_lexical_cast());
0089 }
0090 #else
0091 template <class S, class T>
0092 inline void throw_bad_cast() {
0093 boost::throw_exception(bad_lexical_cast(typeid(S), typeid(T)));
0094 }
0095 #endif
0096 }}
0097
0098 }
0099
0100 #endif