swap boost::reference_wrapper for std::reference_wrapper

This commit is contained in:
Jason Turner 2011-09-10 10:52:59 -06:00
parent 53108463df
commit aa402fdfde
14 changed files with 72 additions and 71 deletions

View File

@ -298,7 +298,7 @@
/// \subsection pointerconversions Pointer / Object Conversions /// \subsection pointerconversions Pointer / Object Conversions
/// ///
/// As much as possible, ChaiScript attempts to convert between &, *, const &, const *, std::shared_ptr<T>, /// As much as possible, ChaiScript attempts to convert between &, *, const &, const *, std::shared_ptr<T>,
/// std::shared_ptr<const T>, boost::reference_wrapper<T>, boost::reference_wrapper<const T> and value types automatically. /// std::shared_ptr<const T>, std::reference_wrapper<T>, std::reference_wrapper<const T> and value types automatically.
/// ///
/// If a chaiscript::var object was created in C++ from a pointer, it cannot be convered to a shared_ptr (this would add invalid reference counting). /// If a chaiscript::var object was created in C++ from a pointer, it cannot be convered to a shared_ptr (this would add invalid reference counting).
/// Const may be added, but never removed. /// Const may be added, but never removed.
@ -315,8 +315,8 @@
/// void fun6(std::shared_ptr<const int>); /// void fun6(std::shared_ptr<const int>);
/// void fun7(const std::shared_ptr<int> &); /// void fun7(const std::shared_ptr<int> &);
/// void fun8(const std::shared_ptr<const int> &); /// void fun8(const std::shared_ptr<const int> &);
/// void fun9(boost::reference_wrapper<int>); /// void fun9(std::reference_wrapper<int>);
/// void fun10(boost::reference_wrapper<const int>); /// void fun10(std::reference_wrapper<const int>);
/// ///
/// int main() /// int main()
/// { /// {

View File

@ -29,14 +29,14 @@ namespace chaiscript
/// \returns Type equivalent to the requested type /// \returns Type equivalent to the requested type
/// \throws exception::bad_boxed_cast If the requested conversion is not possible /// \throws exception::bad_boxed_cast If the requested conversion is not possible
/// ///
/// boxed_cast will attempt to make conversions between value, &, *, std::shared_ptr, boost::reference_wrapper, /// boxed_cast will attempt to make conversions between value, &, *, std::shared_ptr, std::reference_wrapper,
/// and std::function (const and non-const) where possible. boxed_cast is used internally during function /// and std::function (const and non-const) where possible. boxed_cast is used internally during function
/// dispatch. This means that all of these conversions will be attempted automatically for you during /// dispatch. This means that all of these conversions will be attempted automatically for you during
/// ChaiScript function calls. /// ChaiScript function calls.
/// ///
/// \li non-const values can be extracted as const or non-const /// \li non-const values can be extracted as const or non-const
/// \li const values can be extracted only as const /// \li const values can be extracted only as const
/// \li Boxed_Value constructed from pointer or boost::reference_wrapper can be extracted as reference, /// \li Boxed_Value constructed from pointer or std::reference_wrapper can be extracted as reference,
/// pointer or value types /// pointer or value types
/// \li Boxed_Value constructed from std::shared_ptr or value types can be extracted as reference, /// \li Boxed_Value constructed from std::shared_ptr or value types can be extracted as reference,
/// pointer, value, or std::shared_ptr types /// pointer, value, or std::shared_ptr types

View File

@ -26,7 +26,7 @@ namespace chaiscript
template<typename Result> template<typename Result>
struct Cast_Helper_Inner struct Cast_Helper_Inner
{ {
typedef typename boost::reference_wrapper<typename boost::add_const<Result>::type > Result_Type; typedef typename std::reference_wrapper<typename boost::add_const<Result>::type > Result_Type;
static Result_Type cast(const Boxed_Value &ob) static Result_Type cast(const Boxed_Value &ob)
{ {
@ -34,16 +34,16 @@ namespace chaiscript
{ {
if (!ob.get_type_info().is_const()) if (!ob.get_type_info().is_const())
{ {
return boost::cref((boost::any_cast<boost::reference_wrapper<Result> >(ob.get())).get()); return std::cref((boost::any_cast<std::reference_wrapper<Result> >(ob.get())).get());
} else { } else {
return boost::any_cast<boost::reference_wrapper<const Result> >(ob.get()); return boost::any_cast<std::reference_wrapper<const Result> >(ob.get());
} }
} else { } else {
if (!ob.get_type_info().is_const()) if (!ob.get_type_info().is_const())
{ {
return boost::cref(*(boost::any_cast<std::shared_ptr<Result> >(ob.get()))); return std::cref(*(boost::any_cast<std::shared_ptr<Result> >(ob.get())));
} else { } else {
return boost::cref(*(boost::any_cast<std::shared_ptr<const Result> >(ob.get()))); return std::cref(*(boost::any_cast<std::shared_ptr<const Result> >(ob.get())));
} }
} }
} }
@ -76,9 +76,9 @@ namespace chaiscript
{ {
if (!ob.get_type_info().is_const()) if (!ob.get_type_info().is_const())
{ {
return (boost::any_cast<boost::reference_wrapper<Result> >(ob.get())).get_pointer(); return &(boost::any_cast<std::reference_wrapper<Result> >(ob.get())).get();
} else { } else {
return (boost::any_cast<boost::reference_wrapper<const Result> >(ob.get())).get_pointer(); return &(boost::any_cast<std::reference_wrapper<const Result> >(ob.get())).get();
} }
} else { } else {
if (!ob.get_type_info().is_const()) if (!ob.get_type_info().is_const())
@ -103,7 +103,7 @@ namespace chaiscript
{ {
if (ob.is_ref()) if (ob.is_ref())
{ {
return (boost::any_cast<boost::reference_wrapper<Result> >(ob.get())).get_pointer(); return &(boost::any_cast<std::reference_wrapper<Result> >(ob.get())).get();
} else { } else {
return (boost::any_cast<std::shared_ptr<Result> >(ob.get())).get(); return (boost::any_cast<std::shared_ptr<Result> >(ob.get())).get();
} }
@ -116,15 +116,16 @@ namespace chaiscript
template<typename Result> template<typename Result>
struct Cast_Helper_Inner<Result &> struct Cast_Helper_Inner<Result &>
{ {
typedef typename boost::reference_wrapper<Result> Result_Type; typedef Result& Result_Type;
static Result_Type cast(const Boxed_Value &ob) static Result &cast(const Boxed_Value &ob)
{ {
if (ob.is_ref()) if (ob.is_ref())
{ {
return boost::any_cast<boost::reference_wrapper<Result> >(ob.get()); return boost::any_cast<std::reference_wrapper<Result> >(ob.get());
} else { } else {
return boost::ref(*(boost::any_cast<std::shared_ptr<Result> >(ob.get()))); Result &r = *(boost::any_cast<std::shared_ptr<Result> >(ob.get()));
return r;
} }
} }
}; };
@ -220,35 +221,35 @@ namespace chaiscript
/** /**
* Cast_Helper_Inner for casting to a boost::reference_wrapper type * Cast_Helper_Inner for casting to a std::reference_wrapper type
*/ */
template<typename Result> template<typename Result>
struct Cast_Helper_Inner<boost::reference_wrapper<Result> > : Cast_Helper_Inner<Result &> struct Cast_Helper_Inner<std::reference_wrapper<Result> > : Cast_Helper_Inner<Result &>
{ {
}; };
template<typename Result> template<typename Result>
struct Cast_Helper_Inner<const boost::reference_wrapper<Result> > : Cast_Helper_Inner<Result &> struct Cast_Helper_Inner<const std::reference_wrapper<Result> > : Cast_Helper_Inner<Result &>
{ {
}; };
template<typename Result> template<typename Result>
struct Cast_Helper_Inner<const boost::reference_wrapper<Result> &> : Cast_Helper_Inner<Result &> struct Cast_Helper_Inner<const std::reference_wrapper<Result> &> : Cast_Helper_Inner<Result &>
{ {
}; };
template<typename Result> template<typename Result>
struct Cast_Helper_Inner<boost::reference_wrapper<const Result> > : Cast_Helper_Inner<const Result &> struct Cast_Helper_Inner<std::reference_wrapper<const Result> > : Cast_Helper_Inner<const Result &>
{ {
}; };
template<typename Result> template<typename Result>
struct Cast_Helper_Inner<const boost::reference_wrapper<const Result> > : Cast_Helper_Inner<const Result &> struct Cast_Helper_Inner<const std::reference_wrapper<const Result> > : Cast_Helper_Inner<const Result &>
{ {
}; };
template<typename Result> template<typename Result>
struct Cast_Helper_Inner<const boost::reference_wrapper<const Result> & > : Cast_Helper_Inner<const Result &> struct Cast_Helper_Inner<const std::reference_wrapper<const Result> & > : Cast_Helper_Inner<const Result &>
{ {
}; };

View File

@ -103,17 +103,17 @@ namespace chaiscript
template<typename T> template<typename T>
static std::shared_ptr<Data> get(T *t) static std::shared_ptr<Data> get(T *t)
{ {
return get(boost::ref(*t)); return get(std::ref(*t));
} }
template<typename T> template<typename T>
static std::shared_ptr<Data> get(boost::reference_wrapper<T> obj) static std::shared_ptr<Data> get(std::reference_wrapper<T> obj)
{ {
return std::shared_ptr<Data>(new Data( return std::shared_ptr<Data>(new Data(
detail::Get_Type_Info<T>::get(), detail::Get_Type_Info<T>::get(),
boost::any(obj), boost::any(obj),
true, true,
obj.get_pointer()) &obj.get())
); );
} }
@ -271,7 +271,7 @@ namespace chaiscript
std::shared_ptr<Data> m_data; std::shared_ptr<Data> m_data;
}; };
/// \brief Creates a Boxed_Value. If the object passed in is a value type, it is copied. If it is a pointer, std::shared_ptr, or boost::reference_type /// \brief Creates a Boxed_Value. If the object passed in is a value type, it is copied. If it is a pointer, std::shared_ptr, or std::reference_type
/// a copy is not made. /// a copy is not made.
/// \param t The value to box /// \param t The value to box
/// ///
@ -323,19 +323,19 @@ namespace chaiscript
return Boxed_Value( std::const_pointer_cast<typename boost::add_const<T>::type>(t) ); return Boxed_Value( std::const_pointer_cast<typename boost::add_const<T>::type>(t) );
} }
/// \brief Takes a boost::reference_wrapper value, adds const to the referenced type and returns an immutable Boxed_Value. /// \brief Takes a std::reference_wrapper value, adds const to the referenced type and returns an immutable Boxed_Value.
/// Does not copy the referenced value. /// Does not copy the referenced value.
/// \param[in] t Reference object to make immutable /// \param[in] t Reference object to make immutable
/// \returns Immutable Boxed_Value /// \returns Immutable Boxed_Value
/// \sa Boxed_Value::is_const /// \sa Boxed_Value::is_const
template<typename T> template<typename T>
Boxed_Value const_var_impl(const boost::reference_wrapper<T> &t) Boxed_Value const_var_impl(const std::reference_wrapper<T> &t)
{ {
return Boxed_Value( boost::cref(t.get()) ); return Boxed_Value( std::cref(t.get()) );
} }
} }
/// \brief Takes an object and returns an immutable Boxed_Value. If the object is a boost::reference or pointer type /// \brief Takes an object and returns an immutable Boxed_Value. If the object is a std::reference or pointer type
/// the value is not copied. If it is an object type, it is copied. /// the value is not copied. If it is an object type, it is copied.
/// \param[in] t Object to make immutable /// \param[in] t Object to make immutable
/// \returns Immutable Boxed_Value /// \returns Immutable Boxed_Value

View File

@ -112,11 +112,11 @@ namespace chaiscript
{ {
const Derived &d = detail::Cast_Helper<const Derived &>::cast(t_derived); const Derived &d = detail::Cast_Helper<const Derived &>::cast(t_derived);
const Base &data = dynamic_cast<const Base &>(d); const Base &data = dynamic_cast<const Base &>(d);
return Boxed_Value(boost::cref(data)); return Boxed_Value(std::cref(data));
} else { } else {
Derived &d = detail::Cast_Helper<Derived &>::cast(t_derived); Derived &d = detail::Cast_Helper<Derived &>::cast(t_derived);
Base &data = dynamic_cast<Base &>(d); Base &data = dynamic_cast<Base &>(d);
return Boxed_Value(boost::ref(data)); return Boxed_Value(std::ref(data));
} }
} }
} else { } else {

View File

@ -6,7 +6,7 @@
#include <boost/preprocessor.hpp> #include <boost/preprocessor.hpp>
#define addparam(z,n,text) params.push_back((boost::is_reference<Param ## n>::value&&!(boost::is_same<chaiscript::Boxed_Value, typename boost::remove_const<typename boost::remove_reference<Param ## n>::type>::type>::value))?Boxed_Value(boost::ref(BOOST_PP_CAT(p, n))):Boxed_Value(BOOST_PP_CAT(p, n) )); #define addparam(z,n,text) params.push_back((boost::is_reference<Param ## n>::value&&!(boost::is_same<chaiscript::Boxed_Value, typename boost::remove_const<typename boost::remove_reference<Param ## n>::type>::type>::value))?Boxed_Value(std::ref(BOOST_PP_CAT(p, n))):Boxed_Value(BOOST_PP_CAT(p, n) ));
#define curry(z,n,text) BOOST_PP_CAT(std::placeholders::_, BOOST_PP_INC(n)) #define curry(z,n,text) BOOST_PP_CAT(std::placeholders::_, BOOST_PP_INC(n))

View File

@ -75,7 +75,7 @@ namespace chaiscript
{ {
static Boxed_Value handle(const Ret &r) static Boxed_Value handle(const Ret &r)
{ {
return Boxed_Value(boost::cref(r)); return Boxed_Value(std::cref(r));
} }
}; };
@ -88,12 +88,12 @@ namespace chaiscript
{ {
static Boxed_Value handle(Ret &r) static Boxed_Value handle(Ret &r)
{ {
return Boxed_Value(boost::ref(r)); return Boxed_Value(std::ref(r));
} }
static Boxed_Value handle(const Ret &r) static Boxed_Value handle(const Ret &r)
{ {
return Boxed_Value(boost::cref(r)); return Boxed_Value(std::cref(r));
} }
}; };

View File

@ -120,7 +120,7 @@ namespace chaiscript
/// MyClass obj; /// MyClass obj;
/// chaiscript::ChaiScript chai; /// chaiscript::ChaiScript chai;
/// // Add function taking only one argument, an int, and permanently bound to "obj" /// // Add function taking only one argument, an int, and permanently bound to "obj"
/// chai.add(fun(&MyClass::memberfunction, boost::ref(obj)), "memberfunction"); /// chai.add(fun(&MyClass::memberfunction, std::ref(obj)), "memberfunction");
/// \endcode /// \endcode
/// ///
/// \sa \ref addingfunctions /// \sa \ref addingfunctions
@ -146,7 +146,7 @@ namespace chaiscript
/// chaiscript::ChaiScript chai; /// chaiscript::ChaiScript chai;
/// // Add function taking only no arguments, and permanently bound to "obj" and "1" /// // Add function taking only no arguments, and permanently bound to "obj" and "1"
/// // memberfunction() will be equivalent to obj.memberfunction(1) /// // memberfunction() will be equivalent to obj.memberfunction(1)
/// chai.add(fun(&MyClass::memberfunction, boost::ref(obj), 1), "memberfunction"); /// chai.add(fun(&MyClass::memberfunction, std::ref(obj), 1), "memberfunction");
/// \endcode /// \endcode
/// ///
/// \sa \ref addingfunctions /// \sa \ref addingfunctions

View File

@ -187,7 +187,7 @@ namespace chaiscript
}; };
template<typename T> template<typename T>
struct Get_Type_Info<boost::reference_wrapper<T> > struct Get_Type_Info<std::reference_wrapper<T> >
{ {
typedef T type; typedef T type;
@ -196,13 +196,13 @@ namespace chaiscript
return Type_Info(boost::is_const<T>::value, boost::is_reference<T>::value, boost::is_pointer<T>::value, return Type_Info(boost::is_const<T>::value, boost::is_reference<T>::value, boost::is_pointer<T>::value,
boost::is_void<T>::value, boost::is_void<T>::value,
boost::is_arithmetic<T>::value && !boost::is_same<typename boost::remove_const<T>::type, bool>::value, boost::is_arithmetic<T>::value && !boost::is_same<typename boost::remove_const<T>::type, bool>::value,
&typeid(boost::reference_wrapper<T> ), &typeid(std::reference_wrapper<T> ),
&typeid(typename Bare_Type<T>::type)); &typeid(typename Bare_Type<T>::type));
} }
}; };
template<typename T> template<typename T>
struct Get_Type_Info<const boost::reference_wrapper<T> &> struct Get_Type_Info<const std::reference_wrapper<T> &>
{ {
typedef T type; typedef T type;
@ -211,7 +211,7 @@ namespace chaiscript
return Type_Info(boost::is_const<T>::value, boost::is_reference<T>::value, boost::is_pointer<T>::value, return Type_Info(boost::is_const<T>::value, boost::is_reference<T>::value, boost::is_pointer<T>::value,
boost::is_void<T>::value, boost::is_void<T>::value,
boost::is_arithmetic<T>::value && !boost::is_same<typename boost::remove_const<T>::type, bool>::value, boost::is_arithmetic<T>::value && !boost::is_same<typename boost::remove_const<T>::type, bool>::value,
&typeid(const boost::reference_wrapper<T> &), &typeid(const std::reference_wrapper<T> &),
&typeid(typename Bare_Type<T>::type)); &typeid(typename Bare_Type<T>::type));
} }
}; };

View File

@ -344,13 +344,13 @@ namespace chaiscript
add(Bootstrap::bootstrap()); add(Bootstrap::bootstrap());
m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::dump_system, boost::ref(m_engine)), "dump_system"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::dump_system, std::ref(m_engine)), "dump_system");
m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::dump_object, boost::ref(m_engine)), "dump_object"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::dump_object, std::ref(m_engine)), "dump_object");
m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::is_type, boost::ref(m_engine)), "is_type"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::is_type, std::ref(m_engine)), "is_type");
m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::type_name, boost::ref(m_engine)), "type_name"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::type_name, std::ref(m_engine)), "type_name");
m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::function_exists, boost::ref(m_engine)), "function_exists"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::function_exists, std::ref(m_engine)), "function_exists");
m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::get_type_name, boost::ref(m_engine)), "name"); m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::get_type_name, std::ref(m_engine)), "name");
typedef void (ChaiScript::*load_mod_1)(const std::string&); typedef void (ChaiScript::*load_mod_1)(const std::string&);

View File

@ -556,7 +556,7 @@ namespace chaiscript
} }
return Boxed_Value(Proxy_Function(new dispatch::Dynamic_Proxy_Function return Boxed_Value(Proxy_Function(new dispatch::Dynamic_Proxy_Function
(std::bind(chaiscript::eval::detail::eval_function, boost::ref(t_ss), this->children.back(), t_param_names, std::placeholders::_1), (std::bind(chaiscript::eval::detail::eval_function, std::ref(t_ss), this->children.back(), t_param_names, std::placeholders::_1),
static_cast<int>(numparams), this->children.back()))); static_cast<int>(numparams), this->children.back())));
} }
@ -624,7 +624,7 @@ namespace chaiscript
if (guardnode) { if (guardnode) {
guard = std::shared_ptr<dispatch::Dynamic_Proxy_Function> guard = std::shared_ptr<dispatch::Dynamic_Proxy_Function>
(new dispatch::Dynamic_Proxy_Function(std::bind(chaiscript::eval::detail::eval_function, (new dispatch::Dynamic_Proxy_Function(std::bind(chaiscript::eval::detail::eval_function,
boost::ref(t_ss), guardnode, std::ref(t_ss), guardnode,
t_param_names, std::placeholders::_1), static_cast<int>(numparams), guardnode)); t_param_names, std::placeholders::_1), static_cast<int>(numparams), guardnode));
} }
@ -633,7 +633,7 @@ namespace chaiscript
const std::string & l_annotation = this->annotation?this->annotation->text:""; const std::string & l_annotation = this->annotation?this->annotation->text:"";
t_ss.add(Proxy_Function t_ss.add(Proxy_Function
(new dispatch::Dynamic_Proxy_Function(std::bind(chaiscript::eval::detail::eval_function, (new dispatch::Dynamic_Proxy_Function(std::bind(chaiscript::eval::detail::eval_function,
boost::ref(t_ss), this->children.back(), std::ref(t_ss), this->children.back(),
t_param_names, std::placeholders::_1), static_cast<int>(numparams), this->children.back(), t_param_names, std::placeholders::_1), static_cast<int>(numparams), this->children.back(),
l_annotation, guard)), l_function_name); l_annotation, guard)), l_function_name);
} }
@ -942,7 +942,7 @@ namespace chaiscript
throw; throw;
} }
catch (const std::exception &e) { catch (const std::exception &e) {
Boxed_Value except = Boxed_Value(boost::ref(e)); Boxed_Value except = Boxed_Value(std::ref(e));
size_t end_point = this->children.size(); size_t end_point = this->children.size();
if (this->children.back()->identifier == AST_Node_Type::Finally) { if (this->children.back()->identifier == AST_Node_Type::Finally) {
@ -1099,7 +1099,7 @@ namespace chaiscript
if (guardnode) { if (guardnode) {
guard = std::shared_ptr<dispatch::Dynamic_Proxy_Function> guard = std::shared_ptr<dispatch::Dynamic_Proxy_Function>
(new dispatch::Dynamic_Proxy_Function(std::bind(chaiscript::eval::detail::eval_function, (new dispatch::Dynamic_Proxy_Function(std::bind(chaiscript::eval::detail::eval_function,
boost::ref(t_ss), guardnode, std::ref(t_ss), guardnode,
t_param_names, std::placeholders::_1), static_cast<int>(numparams), guardnode)); t_param_names, std::placeholders::_1), static_cast<int>(numparams), guardnode));
} }
@ -1111,7 +1111,7 @@ namespace chaiscript
t_ss.add(Proxy_Function t_ss.add(Proxy_Function
(new dispatch::detail::Dynamic_Object_Constructor(class_name, Proxy_Function (new dispatch::detail::Dynamic_Object_Constructor(class_name, Proxy_Function
(new dispatch::Dynamic_Proxy_Function(std::bind(chaiscript::eval::detail::eval_function, (new dispatch::Dynamic_Proxy_Function(std::bind(chaiscript::eval::detail::eval_function,
boost::ref(t_ss), this->children.back(), std::ref(t_ss), this->children.back(),
t_param_names, std::placeholders::_1), static_cast<int>(numparams), this->children.back(), t_param_names, std::placeholders::_1), static_cast<int>(numparams), this->children.back(),
l_annotation, guard)))), function_name); l_annotation, guard)))), function_name);
@ -1126,7 +1126,7 @@ namespace chaiscript
t_ss.add(Proxy_Function t_ss.add(Proxy_Function
(new dispatch::detail::Dynamic_Object_Function(class_name, Proxy_Function (new dispatch::detail::Dynamic_Object_Function(class_name, Proxy_Function
(new dispatch::Dynamic_Proxy_Function(std::bind(chaiscript::eval::detail::eval_function, (new dispatch::Dynamic_Proxy_Function(std::bind(chaiscript::eval::detail::eval_function,
boost::ref(t_ss), this->children.back(), std::ref(t_ss), this->children.back(),
t_param_names, std::placeholders::_1), static_cast<int>(numparams), this->children.back(), t_param_names, std::placeholders::_1), static_cast<int>(numparams), this->children.back(),
l_annotation, guard)), ti)), function_name); l_annotation, guard)), ti)), function_name);

View File

@ -109,7 +109,7 @@ int main(int /*argc*/, char * /*argv*/[]) {
//Finally, it is possible to register any std::function as a system function, in this //Finally, it is possible to register any std::function as a system function, in this
//way, we can, for instance add a bound member function to the system //way, we can, for instance add a bound member function to the system
chai.add(fun(&System::do_callbacks, boost::ref(system), std::string("Bound Test")), "do_callbacks"); chai.add(fun(&System::do_callbacks, std::ref(system), std::string("Bound Test")), "do_callbacks");
//Call bound version of do_callbacks //Call bound version of do_callbacks
chai("do_callbacks()"); chai("do_callbacks()");

View File

@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
for (int i = 0; i < argc - 1; ++i) for (int i = 0; i < argc - 1; ++i)
{ {
threads.push_back(std::shared_ptr<boost::thread>(new boost::thread(std::bind(do_work, boost::ref(chai))))); threads.push_back(std::shared_ptr<boost::thread>(new boost::thread(std::bind(do_work, std::ref(chai)))));
} }
for (int i = 0; i < argc - 1; ++i) for (int i = 0; i < argc - 1; ++i)

View File

@ -78,14 +78,14 @@ bool do_test(const Boxed_Value &bv, bool T, bool ConstT, bool TRef, bool ConstTR
passed &= test_type_conversion<const std::shared_ptr<const Type> >(bv, ConstSharedConstPtrT); passed &= test_type_conversion<const std::shared_ptr<const Type> >(bv, ConstSharedConstPtrT);
passed &= test_type_conversion<const std::shared_ptr<Type> &>(bv, ConstSharedPtrTRef); passed &= test_type_conversion<const std::shared_ptr<Type> &>(bv, ConstSharedPtrTRef);
passed &= test_type_conversion<const std::shared_ptr<const Type> &>(bv, ConstSharedPtrTConstRef); passed &= test_type_conversion<const std::shared_ptr<const Type> &>(bv, ConstSharedPtrTConstRef);
passed &= test_type_conversion<boost::reference_wrapper<Type> >(bv, BoostRef); passed &= test_type_conversion<std::reference_wrapper<Type> >(bv, BoostRef);
passed &= test_type_conversion<boost::reference_wrapper<const Type> >(bv, BoostConstRef); passed &= test_type_conversion<std::reference_wrapper<const Type> >(bv, BoostConstRef);
passed &= test_type_conversion<boost::reference_wrapper<Type> &>(bv, false); passed &= test_type_conversion<std::reference_wrapper<Type> &>(bv, false);
passed &= test_type_conversion<boost::reference_wrapper<const Type> &>(bv, false); passed &= test_type_conversion<std::reference_wrapper<const Type> &>(bv, false);
passed &= test_type_conversion<const boost::reference_wrapper<Type> >(bv, ConstBoostRef); passed &= test_type_conversion<const std::reference_wrapper<Type> >(bv, ConstBoostRef);
passed &= test_type_conversion<const boost::reference_wrapper<const Type> >(bv, ConstBoostConstRef); passed &= test_type_conversion<const std::reference_wrapper<const Type> >(bv, ConstBoostConstRef);
passed &= test_type_conversion<const boost::reference_wrapper<Type> &>(bv, ConstBoostRefRef); passed &= test_type_conversion<const std::reference_wrapper<Type> &>(bv, ConstBoostRefRef);
passed &= test_type_conversion<const boost::reference_wrapper<const Type> &>(bv, ConstBoostConstRefRef); passed &= test_type_conversion<const std::reference_wrapper<const Type> &>(bv, ConstBoostConstRefRef);
passed &= test_type_conversion<Boxed_Number>(bv, Number); passed &= test_type_conversion<Boxed_Number>(bv, Number);
passed &= test_type_conversion<const Boxed_Number>(bv, ConstNumber); passed &= test_type_conversion<const Boxed_Number>(bv, ConstNumber);
passed &= test_type_conversion<Boxed_Number &>(bv, false); passed &= test_type_conversion<Boxed_Number &>(bv, false);
@ -137,13 +137,13 @@ bool built_in_type_test(const T &initial, bool ispod)
true, false, true, false, true, true, false, true, false, true,
ispod && true, ispod && true, ispod && true, ispod && false, true); ispod && true, ispod && true, ispod && true, ispod && false, true);
passed &= do_test<T>(var(boost::ref(i)), true, true, true, true, true, passed &= do_test<T>(var(std::ref(i)), true, true, true, true, true,
true, true, true, false, false, true, true, true, false, false,
false, false, false, false, true, false, false, false, false, true,
true, true, true, true, true, true, true, true, true, true,
ispod && true, ispod && true, ispod && true, true, true); ispod && true, ispod && true, ispod && true, true, true);
passed &= do_test<T>(var(boost::cref(i)), true, true, false, true, false, passed &= do_test<T>(var(std::cref(i)), true, true, false, true, false,
true, false, true, false, false, true, false, true, false, false,
false, false, false, false, false, false, false, false, false, false,
true, false, true, false, true, true, false, true, false, true,
@ -167,7 +167,7 @@ bool built_in_type_test(const T &initial, bool ispod)
true, false, true, false, true, true, false, true, false, true,
ispod && true, ispod && true, ispod && true, false, true); ispod && true, ispod && true, ispod && true, false, true);
passed &= do_test<T>(var(boost::ref(ir)), true, true, false, true, false, passed &= do_test<T>(var(std::ref(ir)), true, true, false, true, false,
true, false, true, false, false, true, false, true, false, false,
false, false, false, false, false, false, false, false, false, false,
true, false, true, false, true, true, false, true, false, true,
@ -180,7 +180,7 @@ bool built_in_type_test(const T &initial, bool ispod)
true, false, true, false, true, true, false, true, false, true,
ispod && true, ispod && true, ispod && true, false, true); ispod && true, ispod && true, ispod && true, false, true);
passed &= do_test<T>(const_var(boost::ref(ir)), true, true, false, true, false, passed &= do_test<T>(const_var(std::ref(ir)), true, true, false, true, false,
true, false, true, false, false, true, false, true, false, false,
false, false, false, false, false, false, false, false, false, false,
true, false, true, false, true, true, false, true, false, true,