From cdfefed385d673289ec787ee8b0713617bb4c6d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gro=C3=9F?= Date: Mon, 14 May 2012 20:13:39 +0200 Subject: [PATCH 1/2] Add default constructor for Boxed_Number --- include/chaiscript/dispatchkit/boxed_number.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/chaiscript/dispatchkit/boxed_number.hpp b/include/chaiscript/dispatchkit/boxed_number.hpp index 263619a..1cb5811 100644 --- a/include/chaiscript/dispatchkit/boxed_number.hpp +++ b/include/chaiscript/dispatchkit/boxed_number.hpp @@ -297,6 +297,11 @@ namespace chaiscript public: + Boxed_Number() + : bv(Boxed_Value(0)) + { + } + Boxed_Number(const Boxed_Value &v) : bv(v) { From 59dfc847aee0892bceb522f1eaec2b753d9859f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gro=C3=9F?= Date: Mon, 14 May 2012 21:34:28 +0200 Subject: [PATCH 2/2] Make Boxed_Number assignable from Boxed_Value. --- .../chaiscript/dispatchkit/boxed_number.hpp | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/include/chaiscript/dispatchkit/boxed_number.hpp b/include/chaiscript/dispatchkit/boxed_number.hpp index 1cb5811..4814a70 100644 --- a/include/chaiscript/dispatchkit/boxed_number.hpp +++ b/include/chaiscript/dispatchkit/boxed_number.hpp @@ -303,18 +303,8 @@ namespace chaiscript } Boxed_Number(const Boxed_Value &v) - : bv(v) { - const Type_Info &inp_ = v.get_type_info(); - if (inp_ == typeid(bool)) - { - throw boost::bad_any_cast(); - } - - if (!inp_.is_arithmetic()) - { - throw boost::bad_any_cast(); - } + operator=(v); } @@ -383,6 +373,24 @@ namespace chaiscript return oper(Operators::assign_bitwise_and, this->bv, t_rhs.bv); } + Boxed_Number operator=(const Boxed_Value &v) + { + bv = v; + + const Type_Info &inp_ = v.get_type_info(); + if (inp_ == typeid(bool)) + { + throw boost::bad_any_cast(); + } + + if (!inp_.is_arithmetic()) + { + throw boost::bad_any_cast(); + } + + return *this; + } + Boxed_Number operator=(const Boxed_Number &t_rhs) const { return oper(Operators::assign, this->bv, t_rhs.bv);