Add const_var helper function for making const values.
This commit is contained in:
@@ -756,6 +756,30 @@ namespace chaiscript
|
|||||||
return Boxed_Value(t);
|
return Boxed_Value(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Boxed_Value const_var(T *t)
|
||||||
|
{
|
||||||
|
return Boxed_Value( const_cast<typename boost::add_const<T>::type>(t) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Boxed_Value const_var(const boost::shared_ptr<T> &t)
|
||||||
|
{
|
||||||
|
return Boxed_Value( boost::const_pointer_cast<typename boost::add_const<T>::type>(t) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Boxed_Value const_var(const boost::reference_wrapper<T> &t)
|
||||||
|
{
|
||||||
|
return Boxed_Value( boost::cref(t.get()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Boxed_Value const_var(const T &t)
|
||||||
|
{
|
||||||
|
return Boxed_Value(boost::shared_ptr<typename boost::add_const<T>::type >(new T(t)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the two Boxed_Values share the same internal type
|
* Return true if the two Boxed_Values share the same internal type
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user