From 37b2ac2056dac69f6be326810b97d336af51f80d Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 5 Dec 2009 19:30:09 +0000 Subject: [PATCH] Implement proper swap for Boxed_Value --- include/chaiscript/dispatchkit/boxed_value.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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