Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 463273b8 authored by Eric Bruneton's avatar Eric Bruneton
Browse files

compatibility with "C++0x compilers" (shared_ptr in std instead of std::tr1)

git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/ork/trunk@4 28599a00-4e59-401b-b2d8-d34d4661a6c9
parent 16f60d73
Branches
Tags
No related merge requests found
...@@ -28,7 +28,13 @@ ...@@ -28,7 +28,13 @@
#include <cassert> #include <cassert>
#ifdef USE_SHARED_PTR #ifdef USE_SHARED_PTR
#ifdef _MSC_VER
#include <memory>
#define TR1 std
#else
#include <tr1/memory> #include <tr1/memory>
#define TR1 std::tr1
#endif
#else #else
#include "ork/core/Atomic.h" #include "ork/core/Atomic.h"
#endif #endif
...@@ -143,7 +149,7 @@ public: // in fact should be private, but then ptr could not access these member ...@@ -143,7 +149,7 @@ public: // in fact should be private, but then ptr could not access these member
/* /*
* A weak pointer to this object. * A weak pointer to this object.
*/ */
std::tr1::weak_ptr<Object> ref_this; TR1::weak_ptr<Object> ref_this;
/* /*
* Calls the #doRelease method on the given object. * Calls the #doRelease method on the given object.
...@@ -258,20 +264,20 @@ private: ...@@ -258,20 +264,20 @@ private:
*/ */
#ifdef USE_SHARED_PTR #ifdef USE_SHARED_PTR
template <class T> template <class T>
class ptr : public std::tr1::shared_ptr<T> class ptr : public TR1::shared_ptr<T>
{ {
private: private:
template<typename D> template<typename D>
inline ptr(T* target, D d) : std::tr1::shared_ptr<T>(target, d) inline ptr(T* target, D d) : TR1::shared_ptr<T>(target, d)
{ {
target->ref_this = std::tr1::weak_ptr<T>(*this); target->ref_this = TR1::weak_ptr<T>(*this);
} }
public: public:
/** /**
* Creates a pointer pointing to NULL. * Creates a pointer pointing to NULL.
*/ */
inline ptr() : std::tr1::shared_ptr<T>() inline ptr() : TR1::shared_ptr<T>()
{ {
} }
...@@ -279,9 +285,9 @@ public: ...@@ -279,9 +285,9 @@ public:
* Creates a pointer to the given object. * Creates a pointer to the given object.
*/ */
inline ptr(T *target) : inline ptr(T *target) :
std::tr1::shared_ptr<T>(target == NULL ? std::tr1::shared_ptr<T>() : TR1::shared_ptr<T>(target == NULL ? TR1::shared_ptr<T>() :
target->ref_this.expired() ? ptr<T>(target, Object::release) : target->ref_this.expired() ? ptr<T>(target, Object::release) :
std::tr1::dynamic_pointer_cast<T>(std::tr1::shared_ptr<Object>(target->ref_this))) TR1::dynamic_pointer_cast<T>(TR1::shared_ptr<Object>(target->ref_this)))
{ {
} }
...@@ -289,7 +295,7 @@ public: ...@@ -289,7 +295,7 @@ public:
* Creates a pointer as a copy of the given pointer. * Creates a pointer as a copy of the given pointer.
*/ */
template<class U> template<class U>
inline ptr(const std::tr1::shared_ptr<U> &p) : std::tr1::shared_ptr<T>(p) inline ptr(const TR1::shared_ptr<U> &p) : TR1::shared_ptr<T>(p)
{ {
} }
...@@ -297,7 +303,7 @@ public: ...@@ -297,7 +303,7 @@ public:
* Creates a pointer as a copy of the given pointer. * Creates a pointer as a copy of the given pointer.
*/ */
template<class U> template<class U>
inline ptr(const std::tr1::weak_ptr<U> &p) : std::tr1::shared_ptr<T>(p) inline ptr(const TR1::weak_ptr<U> &p) : TR1::shared_ptr<T>(p)
{ {
} }
...@@ -307,7 +313,7 @@ public: ...@@ -307,7 +313,7 @@ public:
template <class U> template <class U>
inline ptr<U> cast() const inline ptr<U> cast() const
{ {
return std::tr1::dynamic_pointer_cast<U>(*this); return TR1::dynamic_pointer_cast<U>(*this);
} }
}; };
#else #else
...@@ -517,4 +523,6 @@ protected: ...@@ -517,4 +523,6 @@ protected:
} }
#undef TR1
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment