|
|
|
@@ -24,10 +24,23 @@
|
|
|
|
|
#define BOOST_SP_NO_SP_CONVERTIBLE
|
|
|
|
|
|
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
#ifdef USE_INTRUSIVE_PTR
|
|
|
|
|
#include <boost/intrusive_ptr.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
using namespace boost;
|
|
|
|
|
|
|
|
|
|
// Can't do using namespace boost;
|
|
|
|
|
// because boost::shared_ptr conflicts with std::tr1::shared_ptr
|
|
|
|
|
// and some boost headers do include boost/shared_ptr themselves
|
|
|
|
|
#if _HAS_TR1
|
|
|
|
|
using std::tr1::shared_ptr;
|
|
|
|
|
#else
|
|
|
|
|
using boost::shared_ptr;
|
|
|
|
|
#endif
|
|
|
|
|
using boost::intrusive_ptr;
|
|
|
|
|
using boost::scoped_ptr;
|
|
|
|
|
using boost::static_pointer_cast;
|
|
|
|
|
using boost::dynamic_pointer_cast;
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- : Declaring
|
|
|
|
|
|
|
|
|
@@ -47,57 +60,6 @@ inline shared_ptr<T> shared(T* ptr) {
|
|
|
|
|
return shared_ptr<T>(ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Allocate a new shared-pointed object
|
|
|
|
|
template <typename T>
|
|
|
|
|
inline shared_ptr<T> new_shared() {
|
|
|
|
|
return shared_ptr<T>(new T());
|
|
|
|
|
}
|
|
|
|
|
/// Allocate a new shared-pointed object, given one argument to pass to the ctor of T
|
|
|
|
|
template <typename T, typename A0>
|
|
|
|
|
inline shared_ptr<T> new_shared1(const A0& a0) {
|
|
|
|
|
return shared_ptr<T>(new T(a0));
|
|
|
|
|
}
|
|
|
|
|
/// Allocate a new shared-pointed object, given two arguments to pass to the ctor of T
|
|
|
|
|
template <typename T, typename A0, typename A1>
|
|
|
|
|
inline shared_ptr<T> new_shared2(const A0& a0, const A1& a1) {
|
|
|
|
|
return shared_ptr<T>(new T(a0, a1));
|
|
|
|
|
}
|
|
|
|
|
/// Allocate a new shared-pointed object, given three arguments to pass to the ctor of T
|
|
|
|
|
template <typename T, typename A0, typename A1, typename A2>
|
|
|
|
|
inline shared_ptr<T> new_shared3(const A0& a0, const A1& a1, const A2& a2) {
|
|
|
|
|
return shared_ptr<T>(new T(a0, a1, a2));
|
|
|
|
|
}
|
|
|
|
|
/// Allocate a new shared-pointed object, given four arguments to pass to the ctor of T
|
|
|
|
|
template <typename T, typename A0, typename A1, typename A2, typename A3>
|
|
|
|
|
inline shared_ptr<T> new_shared4(const A0& a0, const A1& a1, const A2& a2, const A3& a3) {
|
|
|
|
|
return shared_ptr<T>(new T(a0, a1, a2, a3));
|
|
|
|
|
}
|
|
|
|
|
/// Allocate a new shared-pointed object, given five arguments to pass to the ctor of T
|
|
|
|
|
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4>
|
|
|
|
|
inline shared_ptr<T> new_shared5(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4) {
|
|
|
|
|
return shared_ptr<T>(new T(a0, a1, a2, a3, a4));
|
|
|
|
|
}
|
|
|
|
|
/// Allocate a new shared-pointed object, given six arguments to pass to the ctor of T
|
|
|
|
|
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
|
|
|
|
|
inline shared_ptr<T> new_shared6(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) {
|
|
|
|
|
return shared_ptr<T>(new T(a0, a1, a2, a3, a4, a5));
|
|
|
|
|
}
|
|
|
|
|
/// Allocate a new shared-pointed object, given seven arguments to pass to the ctor of T
|
|
|
|
|
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
|
|
|
|
inline shared_ptr<T> new_shared7(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) {
|
|
|
|
|
return shared_ptr<T>(new T(a0, a1, a2, a3, a4, a5, a6));
|
|
|
|
|
}
|
|
|
|
|
/// Allocate a new shared-pointed object, given eight arguments to pass to the ctor of T
|
|
|
|
|
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
|
|
|
|
inline shared_ptr<T> new_shared8(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7) {
|
|
|
|
|
return shared_ptr<T>(new T(a0, a1, a2, a3, a4, a5, a6, a7));
|
|
|
|
|
}
|
|
|
|
|
/// Allocate a new shared-pointed object, given nine arguments to pass to the ctor of T
|
|
|
|
|
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
|
|
|
|
|
inline shared_ptr<T> new_shared9(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) {
|
|
|
|
|
return shared_ptr<T>(new T(a0, a1, a2, a3, a4, a5, a6, a7, a8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------- : Intrusive pointers
|
|
|
|
|
|
|
|
|
|
#ifdef USE_INTRUSIVE_PTR
|
|
|
|
|