5 #ifndef ODB_POINTER_TRAITS_HXX
6 #define ODB_POINTER_TRAITS_HXX
14 #include <odb/details/config.hxx>
15 #include <odb/details/meta/remove-const.hxx>
50 reset (P p = 0) {
delete p_; p_ = p;}
84 static const bool lazy =
false;
89 typedef typename odb::details::meta::remove_const<T>::result*
119 static unrestricted_pointer_type
125 template <
typename T1>
129 return static_cast<T1*
> (p);
132 template <
typename T1>
136 return dynamic_cast<T1*
> (p);
146 return operator new (n);
164 template <
typename T>
169 static const bool lazy =
false;
191 return p.get () == 0;
199 template <
typename T1>
200 static std::auto_ptr<T1>
203 return std::auto_ptr<T1> (
static_cast<T1*
> (p.release ()));
208 template <
typename T1>
209 static std::auto_ptr<T1>
212 T1* p1 (dynamic_cast<T1*> (p.get ()));
217 return std::auto_ptr<T1> (p1);
224 return operator new (n);
238 template <
typename T,
typename D>
239 class pointer_traits<std::unique_ptr<T, D>>
243 static const bool lazy =
false;
245 typedef T element_type;
246 typedef std::unique_ptr<element_type, D> pointer_type;
247 typedef std::unique_ptr<const element_type, D> const_pointer_type;
248 typedef smart_ptr_guard<pointer_type> guard;
251 get_ptr (
const pointer_type& p)
257 get_ref (
const pointer_type& p)
263 null_ptr (
const pointer_type& p)
273 template <
typename T1>
274 static std::unique_ptr<T1>
275 static_pointer_cast (pointer_type& p)
277 return std::unique_ptr<T1> (
static_cast<T1*
> (p.release ()));
282 template <
typename T1>
283 static std::unique_ptr<T1>
284 dynamic_pointer_cast (pointer_type& p)
286 T1* p1 (dynamic_cast<T1*> (p.get ()));
291 return std::unique_ptr<T1> (p1);
296 allocate (std::size_t n)
298 return operator new (n);
310 template <
typename T>
311 class pointer_traits<std::shared_ptr<T>>
315 static const bool lazy =
false;
317 typedef T element_type;
318 typedef std::shared_ptr<element_type> pointer_type;
319 typedef std::shared_ptr<const element_type> const_pointer_type;
320 typedef typename odb::details::meta::remove_const<element_type>::result
321 unrestricted_element_type;
322 typedef std::shared_ptr<unrestricted_element_type>
323 unrestricted_pointer_type;
324 typedef smart_ptr_guard<pointer_type> guard;
327 get_ptr (
const pointer_type& p)
333 get_ref (
const pointer_type& p)
339 null_ptr (
const pointer_type& p)
344 static unrestricted_pointer_type
345 const_pointer_cast (
const pointer_type& p)
347 return std::const_pointer_cast<unrestricted_element_type> (p);
350 template <
typename T1>
351 static std::shared_ptr<T1>
352 static_pointer_cast (
const pointer_type& p)
354 return std::static_pointer_cast<T1> (p);
357 template <
typename T1>
358 static std::shared_ptr<T1>
359 dynamic_pointer_cast (
const pointer_type& p)
361 return std::dynamic_pointer_cast<T1> (p);
366 allocate (std::size_t n)
368 return operator new (n);
380 template <
typename T>
381 class pointer_traits<std::weak_ptr<T>>
385 static const bool lazy =
false;
387 typedef T element_type;
388 typedef std::weak_ptr<element_type> pointer_type;
389 typedef std::shared_ptr<element_type> strong_pointer_type;
391 static strong_pointer_type
392 lock (
const pointer_type& p)
404 #endif // ODB_POINTER_TRAITS_HXX
static T1 * dynamic_pointer_cast(pointer_type p)
Definition: pointer-traits.hxx:134
Definition: pointer-traits.hxx:37
static void * allocate(std::size_t n)
Definition: pointer-traits.hxx:222
Definition: pointer-traits.hxx:24
Definition: pointer-traits.hxx:23
smart_ptr_guard(const P &)
Definition: pointer-traits.hxx:65
static std::auto_ptr< T1 > dynamic_pointer_cast(pointer_type &p)
Definition: pointer-traits.hxx:210
const T * const_pointer_type
Definition: pointer-traits.hxx:88
raw_ptr_guard(P p)
Definition: pointer-traits.hxx:44
static T1 * static_pointer_cast(pointer_type p)
Definition: pointer-traits.hxx:127
Definition: pointer-traits.hxx:28
T element_type
Definition: pointer-traits.hxx:171
void release()
Definition: pointer-traits.hxx:68
static element_type & get_ref(const pointer_type &p)
Definition: pointer-traits.hxx:183
static element_type & get_ref(pointer_type p)
Definition: pointer-traits.hxx:104
static bool null_ptr(const pointer_type &p)
Definition: pointer-traits.hxx:189
void reset(P p=0)
Definition: pointer-traits.hxx:50
std::auto_ptr< element_type > pointer_type
Definition: pointer-traits.hxx:172
void reset(const P &)
Definition: pointer-traits.hxx:74
smart_ptr_guard()
Definition: pointer-traits.hxx:62
Definition: pointer-traits.hxx:59
T element_type
Definition: pointer-traits.hxx:86
odb::details::meta::remove_const< T >::result * unrestricted_pointer_type
Definition: pointer-traits.hxx:90
static unrestricted_pointer_type const_pointer_cast(pointer_type p)
Definition: pointer-traits.hxx:120
static element_type * get_ptr(const pointer_type &p)
Definition: pointer-traits.hxx:177
static std::auto_ptr< T1 > static_pointer_cast(pointer_type &p)
Definition: pointer-traits.hxx:201
static void free(void *p)
Definition: pointer-traits.hxx:228
std::auto_ptr< const element_type > const_pointer_type
Definition: pointer-traits.hxx:173
raw_ptr_guard()
Definition: pointer-traits.hxx:41
T * pointer_type
Definition: pointer-traits.hxx:87
static void * allocate(std::size_t n)
Definition: pointer-traits.hxx:144
raw_ptr_guard< pointer_type > guard
Definition: pointer-traits.hxx:91
static element_type * get_ptr(pointer_type p)
Definition: pointer-traits.hxx:96
~raw_ptr_guard()
Definition: pointer-traits.hxx:40
Definition: pointer-traits.hxx:21
void release()
Definition: pointer-traits.hxx:47
void reset()
Definition: pointer-traits.hxx:71
static void free(void *p)
Definition: pointer-traits.hxx:156
static bool null_ptr(pointer_type p)
Definition: pointer-traits.hxx:112
smart_ptr_guard< pointer_type > guard
Definition: pointer-traits.hxx:174
Definition: pointer-traits.hxx:22
pointer_kind
Definition: pointer-traits.hxx:19