diff --git a/include/chaiscript/dispatchkit/boxed_number.hpp b/include/chaiscript/dispatchkit/boxed_number.hpp index 1fe4e95..ccb93d1 100644 --- a/include/chaiscript/dispatchkit/boxed_number.hpp +++ b/include/chaiscript/dispatchkit/boxed_number.hpp @@ -298,7 +298,12 @@ namespace chaiscript throw boost::bad_any_cast(); } } - + + template + Target getAsAux() + { + return static_cast(*static_cast(bv.get_const_ptr())); + } public: @@ -319,6 +324,47 @@ namespace chaiscript validate_boxed_number(bv); } + template Target getAs() + { + const Type_Info &inp_ = bv.get_type_info(); + + if (inp_ == typeid(int)) { + return getAsAux(); + } else if (inp_ == typeid(double)) { + return getAsAux(); + } else if (inp_ == typeid(float)) { + return getAsAux(); + } else if (inp_ == typeid(long double)) { + return getAsAux(); + } else if (inp_ == typeid(char)) { + return getAsAux(); + } else if (inp_ == typeid(unsigned int)) { + return getAsAux(); + } else if (inp_ == typeid(long)) { + return getAsAux(); + } else if (inp_ == typeid(unsigned long)) { + return getAsAux(); + } else if (inp_ == typeid(boost::int8_t)) { + return getAsAux(); + } else if (inp_ == typeid(boost::int16_t)) { + return getAsAux(); + } else if (inp_ == typeid(boost::int32_t)) { + return getAsAux(); + } else if (inp_ == typeid(boost::int64_t)) { + return getAsAux(); + } else if (inp_ == typeid(boost::uint8_t)) { + return getAsAux(); + } else if (inp_ == typeid(boost::uint16_t)) { + return getAsAux(); + } else if (inp_ == typeid(boost::uint32_t)) { + return getAsAux(); + } else if (inp_ == typeid(boost::uint64_t)) { + return getAsAux(); + } else { + throw boost::bad_any_cast(); + } + } + bool operator==(const Boxed_Number &t_rhs) const { return boxed_cast(oper(Operators::equals, this->bv, t_rhs.bv));