From 4b40812e2600a969843f97401e53a53a832d1406 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 6 Sep 2009 02:09:19 +0000 Subject: [PATCH] Add const_var helper function for making const values. --- .../chaiscript/dispatchkit/boxed_value.hpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/chaiscript/dispatchkit/boxed_value.hpp b/include/chaiscript/dispatchkit/boxed_value.hpp index e003fc52..337f68a5 100644 --- a/include/chaiscript/dispatchkit/boxed_value.hpp +++ b/include/chaiscript/dispatchkit/boxed_value.hpp @@ -756,6 +756,30 @@ namespace chaiscript return Boxed_Value(t); } + template + Boxed_Value const_var(T *t) + { + return Boxed_Value( const_cast::type>(t) ); + } + + template + Boxed_Value const_var(const boost::shared_ptr &t) + { + return Boxed_Value( boost::const_pointer_cast::type>(t) ); + } + + template + Boxed_Value const_var(const boost::reference_wrapper &t) + { + return Boxed_Value( boost::cref(t.get()) ); + } + + template + Boxed_Value const_var(const T &t) + { + return Boxed_Value(boost::shared_ptr::type >(new T(t))); + } + /** * Return true if the two Boxed_Values share the same internal type */