diff --git a/include/chaiscript/dispatchkit/boxed_number.hpp b/include/chaiscript/dispatchkit/boxed_number.hpp index 3541bfb..e1a5ca7 100644 --- a/include/chaiscript/dispatchkit/boxed_number.hpp +++ b/include/chaiscript/dispatchkit/boxed_number.hpp @@ -337,7 +337,7 @@ namespace chaiscript Boxed_Number(Boxed_Value v) : bv(std::move(v)) { - validate_boxed_number(v); + validate_boxed_number(bv); } template explicit Boxed_Number(T t) diff --git a/include/chaiscript/dispatchkit/boxed_value.hpp b/include/chaiscript/dispatchkit/boxed_value.hpp index 3fe48b0..374036b 100644 --- a/include/chaiscript/dispatchkit/boxed_value.hpp +++ b/include/chaiscript/dispatchkit/boxed_value.hpp @@ -61,9 +61,6 @@ namespace chaiscript Data(const Data &) = delete; - ~Data() - { - } Type_Info m_type_info; chaiscript::detail::Any m_obj; @@ -151,21 +148,18 @@ namespace chaiscript { } - /// Copy constructor - each copy shares the same data pointer - Boxed_Value(const Boxed_Value &t_so) - : m_data(t_so.m_data) - { - } - /// Unknown-type constructor Boxed_Value() : m_data(Object_Data::get()) { } - ~Boxed_Value() - { - } + + Boxed_Value(Boxed_Value&&) = default; + Boxed_Value& operator=(Boxed_Value&&) = default; + + Boxed_Value(const Boxed_Value&) = default; + Boxed_Value& operator=(const Boxed_Value&) = default; void swap(Boxed_Value &rhs) { @@ -180,61 +174,53 @@ namespace chaiscript return *this; } - /// shared data assignment, same as copy construction - Boxed_Value &operator=(const Boxed_Value &rhs) - { - Boxed_Value temp(rhs); - swap(temp); - return *this; - } - - const Type_Info &get_type_info() const + const Type_Info &get_type_info() const CHAISCRIPT_NOEXCEPT { return m_data->m_type_info; } /// return true if the object is uninitialized - bool is_undef() const + bool is_undef() const CHAISCRIPT_NOEXCEPT { return m_data->m_type_info.is_undef(); } - bool is_const() const + bool is_const() const CHAISCRIPT_NOEXCEPT { return m_data->m_type_info.is_const(); } - bool is_type(const Type_Info &ti) const + bool is_type(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { return m_data->m_type_info.bare_equal(ti); } - bool is_null() const + bool is_null() const CHAISCRIPT_NOEXCEPT { return (m_data->m_data_ptr == nullptr && m_data->m_const_data_ptr == nullptr); } - const chaiscript::detail::Any & get() const + const chaiscript::detail::Any & get() const CHAISCRIPT_NOEXCEPT { return m_data->m_obj; } - bool is_ref() const + bool is_ref() const CHAISCRIPT_NOEXCEPT { return m_data->m_is_ref; } - bool is_pointer() const + bool is_pointer() const CHAISCRIPT_NOEXCEPT { return !is_ref(); } - void *get_ptr() const + void *get_ptr() const CHAISCRIPT_NOEXCEPT { return m_data->m_data_ptr; } - const void *get_const_ptr() const + const void *get_const_ptr() const CHAISCRIPT_NOEXCEPT { return m_data->m_const_data_ptr; } @@ -260,7 +246,7 @@ namespace chaiscript /// \returns true if the two Boxed_Values share the same internal type - static bool type_match(Boxed_Value l, Boxed_Value r) + static bool type_match(const Boxed_Value &l, const Boxed_Value &r) CHAISCRIPT_NOEXCEPT { return l.get_type_info() == r.get_type_info(); } diff --git a/include/chaiscript/dispatchkit/type_info.hpp b/include/chaiscript/dispatchkit/type_info.hpp index 628b4bb..f287033 100644 --- a/include/chaiscript/dispatchkit/type_info.hpp +++ b/include/chaiscript/dispatchkit/type_info.hpp @@ -39,7 +39,7 @@ namespace chaiscript { } - Type_Info() + CHAISCRIPT_CONSTEXPR Type_Info() : m_type_info(nullptr), m_bare_type_info(nullptr), m_is_const(false), m_is_reference(false), m_is_pointer(false), m_is_void(false), m_is_arithmetic(false), @@ -47,63 +47,47 @@ namespace chaiscript { } - Type_Info(const Type_Info &ti) - : m_type_info(ti.m_type_info), - m_bare_type_info(ti.m_bare_type_info), - m_is_const(ti.m_is_const), m_is_reference(ti.m_is_reference), - m_is_pointer(ti.m_is_pointer), - m_is_void(ti.m_is_void), m_is_arithmetic(ti.m_is_arithmetic), - m_is_undef(ti.m_is_undef) - { - } + Type_Info(Type_Info&&) = default; + Type_Info& operator=(Type_Info&&) = default; - Type_Info &operator=(const Type_Info &ti) - { - m_type_info = ti.m_type_info; - m_bare_type_info = ti.m_bare_type_info; - m_is_const = ti.m_is_const; - m_is_reference = ti.m_is_reference; - m_is_pointer = ti.m_is_pointer; - m_is_void = ti.m_is_void; - m_is_arithmetic = ti.m_is_arithmetic; - m_is_undef = ti.m_is_undef; - return *this; - } + Type_Info(const Type_Info&) = default; + Type_Info& operator=(const Type_Info&) = default; - bool operator<(const Type_Info &ti) const + + CHAISCRIPT_CONSTEXPR bool operator<(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { return m_type_info < ti.m_type_info; } - bool operator==(const Type_Info &ti) const + CHAISCRIPT_CONSTEXPR bool operator==(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { return ti.m_type_info == m_type_info || (ti.m_type_info && m_type_info && *ti.m_type_info == *m_type_info); } - bool operator==(const std::type_info &ti) const + CHAISCRIPT_CONSTEXPR bool operator==(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT { return m_type_info != nullptr && (*m_type_info) == ti; } - bool bare_equal(const Type_Info &ti) const + CHAISCRIPT_CONSTEXPR bool bare_equal(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT { return ti.m_bare_type_info == m_bare_type_info || (ti.m_bare_type_info && m_bare_type_info && *ti.m_bare_type_info == *m_bare_type_info); } - bool bare_equal_type_info(const std::type_info &ti) const + CHAISCRIPT_CONSTEXPR bool bare_equal_type_info(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT { return m_bare_type_info != nullptr && (*m_bare_type_info) == ti; } - bool is_const() const { return m_is_const; } - bool is_reference() const { return m_is_reference; } - bool is_void() const { return m_is_void; } - bool is_arithmetic() const { return m_is_arithmetic; } - bool is_undef() const { return m_is_undef || m_bare_type_info == nullptr; } - bool is_pointer() const { return m_is_pointer; } + CHAISCRIPT_CONSTEXPR bool is_const() const CHAISCRIPT_NOEXCEPT { return m_is_const; } + CHAISCRIPT_CONSTEXPR bool is_reference() const CHAISCRIPT_NOEXCEPT { return m_is_reference; } + CHAISCRIPT_CONSTEXPR bool is_void() const CHAISCRIPT_NOEXCEPT { return m_is_void; } + CHAISCRIPT_CONSTEXPR bool is_arithmetic() const CHAISCRIPT_NOEXCEPT { return m_is_arithmetic; } + CHAISCRIPT_CONSTEXPR bool is_undef() const CHAISCRIPT_NOEXCEPT { return m_is_undef || m_bare_type_info == nullptr; } + CHAISCRIPT_CONSTEXPR bool is_pointer() const CHAISCRIPT_NOEXCEPT { return m_is_pointer; } std::string name() const { @@ -115,7 +99,7 @@ namespace chaiscript } } - std::string bare_name() const + std::string bare_name() const { if (m_bare_type_info) {