From f547b4bb1021cfb2f93d2c2bc5dd2a773d87727d Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 5 Oct 2014 12:11:46 -0600 Subject: [PATCH] Enable moving of data into Boxed_Values when possible --- include/chaiscript/dispatchkit/boxed_value.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/chaiscript/dispatchkit/boxed_value.hpp b/include/chaiscript/dispatchkit/boxed_value.hpp index 8d272cb..dd8c210 100644 --- a/include/chaiscript/dispatchkit/boxed_value.hpp +++ b/include/chaiscript/dispatchkit/boxed_value.hpp @@ -132,9 +132,9 @@ namespace chaiscript } template - static std::shared_ptr get(const T& t) + static std::shared_ptr get(T t) { - auto p = std::make_shared(t); + auto p = std::make_shared(std::move(t)); auto ptr = p.get(); return std::make_shared( detail::Get_Type_Info::get(), @@ -158,9 +158,10 @@ namespace chaiscript public: /// Basic Boxed_Value constructor - template - explicit Boxed_Value(T t) - : m_data(Object_Data::get(t)) + template::type>::value>::type> + explicit Boxed_Value(T &&t) + : m_data(Object_Data::get(std::forward(t))) { }