diff --git a/boxedcpp/boxedcpp.hpp b/boxedcpp/boxedcpp.hpp index bcf7066..589b20e 100644 --- a/boxedcpp/boxedcpp.hpp +++ b/boxedcpp/boxedcpp.hpp @@ -41,6 +41,17 @@ class BoxedCPP_System m_functions.insert(std::make_pair(name, boost::shared_ptr(new Proxy_Function_Impl(func)))); } + + template + void set_object(const std::string &name, const Class &obj) + { + try { + get_object(name) = Boxed_Value(obj); + } catch (const std::range_error &) { + add_object(name, obj); + } + } + template void add_object(const std::string &name, const Class &obj) {