48 #include <boost/version.hpp> 59 #if !defined(USE_REFCOUNT_POINTERS) && BOOST_VERSION >= 103300 60 #if __cplusplus > 199711L 62 #define refcount std::shared_ptr 63 #define Wrefcount std::weak_ptr 64 #define RefcountCast std::dynamic_pointer_cast 67 #include <boost/smart_ptr/shared_ptr.hpp> 68 #include <boost/smart_ptr/weak_ptr.hpp> 71 #define refcount boost::shared_ptr 72 #define Wrefcount boost::weak_ptr 73 #define RefcountCast boost::dynamic_pointer_cast 104 Ref(T* p) : ptr(p), count(1), deleter(1)
107 template <
class null_deleter>
123 return (--count == 0);
128 explicit refcount(T* p = 0) : ref(p ? new Ref(p) : 0)
131 template <
class null_deleter>
141 if(ref && ref->decrement())
148 if(ref && ref->decrement())
155 return this->
get() == other.
get();
159 return ref ? ref->ptr : 0;
167 return ref ? ref->ptr : 0;
171 return ref ? ref->ptr : 0;
173 template <
class newType>
180 template <
typename T>
223 #define REF_FORWARD_DECL(obj) \ 225 typedef refcount<obj> obj##Ref 226 #define CONSTREF_FORWARD_DECL(obj) \ 228 typedef refcount<const obj> obj##ConstRef 236 template <
class T,
class U>
239 return dynamic_cast<T*
>(t.
get());
248 template <
class T,
class U>
251 return static_cast<T*
>(t.
get());
254 #include <functional> 255 #if !defined(USE_REFCOUNT_POINTERS) && BOOST_VERSION >= 103300 && __cplusplus > 199711L 259 template <
typename T>
260 struct hash<
refcount<T>> :
public std::unary_function<refcount<T>, std::size_t>
264 std::hash<const void*> hasher;
265 return hasher(val.
get());
274 template <
typename T>
288 return *(x.
get()) < *(y.
get());
refcount< T > & operator=(const refcount< T > &other)
bool operator==(const refcount< T > &other)
Wrefcount< T > & operator=(refcount< T > const &other)
bool operator()(const refcount< T > x, const refcount< T > y) const
Compare of refcount object.
Definition of hash function for EdgeDescriptor.
The key comparison function for refcount.
void operator()(void const *) const
deallocator
refcount(T *p, null_deleter &d)
refcount< T > lock() const
T * GetPointer(const refcount< U > &t)
Template function used to hide dynamic_cast The template parameter T represents a type of an object h...
T * GetPointerS(const refcount< U > &t)
Template function used to hide static_cast The template parameter T represents a type of an object ha...
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
std::size_t operator()(const refcount< T > &val) const
Wrefcount(refcount< T > const &other)
refcount(const refcount< T > &other)
x
Return the smallest n such that 2^n >= _x.
Wrefcount< T > & operator=(Wrefcount< T > const &other)
Wrefcount(Wrefcount< T > const &other)
struct refcount::Ref * ref
Ref(T *p, null_deleter &d)