1 #ifndef BOOSTER_SMART_PTR_WEAK_PTR_HPP_INCLUDED 2 #define BOOSTER_SMART_PTR_WEAK_PTR_HPP_INCLUDED 16 #include <booster/auto_ptr_inc.h> 17 #include <booster/smart_ptr/shared_count.h> 18 #include <booster/shared_ptr.h> 20 #ifdef BOOSTER_MSVC // moved here to work around VC++ compiler crash 21 # pragma warning(push) 22 # pragma warning(disable:4284) // odd return type for operator-> 28 template<
class T>
class weak_ptr
33 typedef weak_ptr<T> this_type;
37 typedef T element_type;
39 weak_ptr(): px(0), pn()
64 weak_ptr( weak_ptr<Y>
const & r,
typename detail::sp_enable_if_convertible<Y,T>::type = detail::sp_empty() )
65 : px(r.lock().get()), pn(r.pn)
71 weak_ptr( shared_ptr<Y>
const & r,
typename detail::sp_enable_if_convertible<Y,T>::type = detail::sp_empty() )
72 : px( r.px ), pn( r.pn )
77 weak_ptr & operator=(weak_ptr<Y>
const & r)
85 weak_ptr & operator=(shared_ptr<Y>
const & r)
92 shared_ptr<T> lock() const
97 long use_count() const
99 return pn.use_count();
104 return pn.use_count() == 0;
114 this_type().swap(*
this);
117 void swap(this_type & other)
119 std::swap(px, other.px);
129 template<
class Y>
bool _internal_less(weak_ptr<Y>
const & rhs)
const 139 template<
class Y>
friend class weak_ptr;
140 template<
class Y>
friend class shared_ptr;
147 template<
class T,
class U>
inline bool operator<(weak_ptr<T>
const & a, weak_ptr<U>
const & b)
149 return a._internal_less(b);
152 template<
class T>
void swap(weak_ptr<T> & a, weak_ptr<T> & b)
160 # pragma warning(pop) 163 #endif // #ifndef BOOST_SMART_PTR_WEAK_PTR_HPP_INCLUDED Definition: shared_count.h:37
Definition: shared_count.h:179
Definition: shared_count.h:33
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23