MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / bad_boxed_cast

Class bad_boxed_cast

include/chaiscript/dispatchkit/bad_boxed_cast.hpp:33–66  ·  view source on GitHub ↗

\brief Thrown in the event that a Boxed_Value cannot be cast to the desired type It is used internally during function dispatch and may be used by the end user. \sa chaiscript::boxed_cast

Source from the content-addressed store, hash-verified

31 ///
32 /// \sa chaiscript::boxed_cast
33 class bad_boxed_cast : public std::bad_cast
34 {
35 public:
36 bad_boxed_cast(Type_Info t_from, const std::type_info &t_to,
37 std::string t_what) noexcept
38 : from(t_from), to(&t_to), m_what(std::move(t_what))
39 {
40 }
41
42 bad_boxed_cast(Type_Info t_from, const std::type_info &t_to)
43 : from(t_from), to(&t_to), m_what("Cannot perform boxed_cast: " + t_from.name() + " to: " + t_to.name())
44 {
45 }
46
47 explicit bad_boxed_cast(std::string t_what) noexcept
48 : m_what(std::move(t_what))
49 {
50 }
51
52 bad_boxed_cast(const bad_boxed_cast &) = default;
53 ~bad_boxed_cast() noexcept override = default;
54
55 /// \brief Description of what error occurred
56 const char * what() const noexcept override
57 {
58 return m_what.c_str();
59 }
60
61 Type_Info from; ///< Type_Info contained in the Boxed_Value
62 const std::type_info *to = nullptr; ///< std::type_info of the desired (but failed) result type
63
64 private:
65 std::string m_what;
66 };
67 }
68}
69

Callers 4

ptr_assignFunction · 0.70
unknown_assignMethod · 0.70
functorFunction · 0.70
boxed_castFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected