Common ODB Runtime Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
tr1/wrapper-traits.hxx
Go to the documentation of this file.
1 // file : odb/tr1/wrapper-traits.hxx
2 // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
3 // license : GNU GPL v2; see accompanying LICENSE file
4 
5 #ifndef ODB_TR1_WRAPPER_TRAITS_HXX
6 #define ODB_TR1_WRAPPER_TRAITS_HXX
7 
8 #include <odb/pre.hxx>
9 
10 #include <odb/details/config.hxx> // ODB_CXX11
11 
12 // In VC++ std::shared_ptr and std::tr1::shared_ptr is the same class
13 // template. One is just a using-declaration for the other.
14 //
15 #if !(defined(ODB_CXX11) && defined(_MSC_VER))
16 
17 //
18 // This header assumes that the necessary TR1 header has already
19 // been included.
20 //
21 
22 #include <odb/wrapper-traits.hxx>
23 
24 namespace odb
25 {
26  // Specialization for std::tr1::shared_ptr.
27  //
28  template <typename T>
29  class wrapper_traits< std::tr1::shared_ptr<T> >
30  {
31  public:
32  typedef T wrapped_type;
33  typedef std::tr1::shared_ptr<T> wrapper_type;
34 
35  // T can be const.
36  //
37  typedef
38  typename odb::details::meta::remove_const<T>::result
40 
41  static const bool null_handler = true;
42  static const bool null_default = false;
43 
44  static bool
46  {
47  return !p;
48  }
49 
50  static void
52  {
53  p.reset ();
54  }
55 
56  static const wrapped_type&
57  get_ref (const wrapper_type& p)
58  {
59  return *p;
60  }
61 
62  static unrestricted_wrapped_type&
64  {
65  if (!p)
66  p.reset (new unrestricted_wrapped_type);
67 
68  return const_cast<unrestricted_wrapped_type&> (*p);
69  }
70  };
71 }
72 
73 #endif // !(ODB_CXX11 && _MSC_VER)
74 
75 #include <odb/post.hxx>
76 
77 #endif // ODB_TR1_WRAPPER_TRAITS_HXX
static void set_null(wrapper_type &p)
Definition: tr1/wrapper-traits.hxx:51
static bool get_null(const wrapper_type &p)
Definition: tr1/wrapper-traits.hxx:45
std::tr1::shared_ptr< T > wrapper_type
Definition: tr1/wrapper-traits.hxx:33
Definition: wrapper-traits.hxx:20
T wrapped_type
Definition: tr1/wrapper-traits.hxx:32
odb::details::meta::remove_const< T >::result unrestricted_wrapped_type
Definition: tr1/wrapper-traits.hxx:39
static unrestricted_wrapped_type & set_ref(wrapper_type &p)
Definition: tr1/wrapper-traits.hxx:63
static const wrapped_type & get_ref(const wrapper_type &p)
Definition: tr1/wrapper-traits.hxx:57