mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
Instead of the new_intrusive<T>() functions, use intrusive(new T)
This means we no longer need 8 different functions for different numbers of arguments, and non-const references can now also be passed to constructors without problems. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1443 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+16
-60
@@ -38,6 +38,15 @@ using namespace boost;
|
||||
|
||||
// ----------------------------------------------------------------------------- : Creating
|
||||
|
||||
/// Wrap a newly allocated pointer in an shared_ptr
|
||||
/** Usage:
|
||||
* return shared(new T(stuff)));
|
||||
*/
|
||||
template <typename T>
|
||||
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() {
|
||||
@@ -98,58 +107,15 @@ inline shared_ptr<T> new_shared9(const A0& a0, const A1& a1, const A2& a2, const
|
||||
class Type; \
|
||||
typedef intrusive_ptr<Type> Type##P;
|
||||
|
||||
|
||||
/// Allocate a new intrusive-pointed object
|
||||
/// Wrap a newly allocated pointer in an intrusive_ptr
|
||||
/** Usage:
|
||||
* return intrusive(new T(stuff)));
|
||||
*/
|
||||
template <typename T>
|
||||
inline intrusive_ptr<T> new_intrusive() {
|
||||
return intrusive_ptr<T>(new T());
|
||||
inline intrusive_ptr<T> intrusive(T* ptr) {
|
||||
return intrusive_ptr<T>(ptr);
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given one argument to pass to the ctor of T
|
||||
template <typename T, typename A0>
|
||||
inline intrusive_ptr<T> new_intrusive1(const A0& a0) {
|
||||
return intrusive_ptr<T>(new T(a0));
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given two arguments to pass to the ctor of T
|
||||
template <typename T, typename A0, typename A1>
|
||||
inline intrusive_ptr<T> new_intrusive2(const A0& a0, const A1& a1) {
|
||||
return intrusive_ptr<T>(new T(a0, a1));
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given three arguments to pass to the ctor of T
|
||||
template <typename T, typename A0, typename A1, typename A2>
|
||||
inline intrusive_ptr<T> new_intrusive3(const A0& a0, const A1& a1, const A2& a2) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2));
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given four arguments to pass to the ctor of T
|
||||
template <typename T, typename A0, typename A1, typename A2, typename A3>
|
||||
inline intrusive_ptr<T> new_intrusive4(const A0& a0, const A1& a1, const A2& a2, const A3& a3) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2, a3));
|
||||
}
|
||||
/// Allocate a new intrusive-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 intrusive_ptr<T> new_intrusive5(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2, a3, a4));
|
||||
}
|
||||
/// Allocate a new intrusive-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 intrusive_ptr<T> new_intrusive6(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2, a3, a4, a5));
|
||||
}
|
||||
/// Allocate a new intrusive-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 intrusive_ptr<T> new_intrusive7(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
/// Allocate a new intrusive-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 intrusive_ptr<T> new_intrusive8(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 intrusive_ptr<T>(new T(a0, a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
/// Allocate a new intrusive-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 intrusive_ptr<T> new_intrusive9(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 intrusive_ptr<T>(new T(a0, a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Intrusive pointer base
|
||||
|
||||
template <typename T> class IntrusivePtrBase;
|
||||
@@ -215,16 +181,6 @@ inline shared_ptr<T> new_shared9(const A0& a0, const A1& a1, const A2& a2, const
|
||||
#else
|
||||
#define DECLARE_POINTER_TYPE DECLARE_SHARED_POINTER_TYPE
|
||||
#define intrusive_ptr shared_ptr
|
||||
#define new_intrusive new_shared
|
||||
#define new_intrusive1 new_shared1
|
||||
#define new_intrusive2 new_shared2
|
||||
#define new_intrusive3 new_shared3
|
||||
#define new_intrusive4 new_shared4
|
||||
#define new_intrusive5 new_shared5
|
||||
#define new_intrusive6 new_shared6
|
||||
#define new_intrusive7 new_shared7
|
||||
#define new_intrusive8 new_shared8
|
||||
#define new_intrusive9 new_shared9
|
||||
|
||||
template <typename T> class IntrusivePtrBase {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user