diff --git a/include/chaiscript/dispatchkit/boxed_value.hpp b/include/chaiscript/dispatchkit/boxed_value.hpp index 45f2ca0..0d0d77a 100644 --- a/include/chaiscript/dispatchkit/boxed_value.hpp +++ b/include/chaiscript/dispatchkit/boxed_value.hpp @@ -264,6 +264,11 @@ namespace chaiscript { } + void swap(Boxed_Value &rhs) + { + std::swap(m_data, rhs.m_data); + } + /** * Return a reference to the static global Object_Cache */ @@ -293,7 +298,8 @@ namespace chaiscript */ Boxed_Value &operator=(const Boxed_Value &rhs) { - m_data = rhs.m_data; + Boxed_Value temp(rhs); + swap(temp); return *this; } @@ -896,7 +902,14 @@ namespace chaiscript { return l.get_type_info() == r.get_type_info(); } +} +namespace std +{ + template<> void swap(chaiscript::Boxed_Value &lhs, chaiscript::Boxed_Value &rhs) + { + lhs.swap(rhs); + } } #endif