Class documentation of Concepts

Loading...
Searching...
No Matches
sharedPointer_std.hh
Go to the documentation of this file.
1
4#pragma once
5
6
7#include <memory>
8
9namespace concepts {
10
11 // ********************************************************** null_deleter **
12
13 struct null_deleter
14 {
15 void operator()(void const *) const
16 {
17 }
18 };
19
20 // ******************************************************************* RCP **
21
27 template<class T>
28 class RCP : public std::shared_ptr<T>
29 {
30 public:
32 RCP() : std::shared_ptr<T>() {}
33
46 explicit RCP(T* x) : std::shared_ptr<T>(x) {}
47
48 RCP(std::shared_ptr<T>& x) : std::shared_ptr<T>(x) {}
49
50 template<class F>
51 RCP(const std::shared_ptr<F>& x) : std::shared_ptr<T>(x) {}
52
54 template<class F, class G>
55 RCP(F x, G y) : std::shared_ptr<T>(x, y) {}
56
57 RCP<T>& operator=(const RCP<T> x)
58 {
59 RCP<T>(x).swap(*this);
60 return *this;
61 }
62
63 template<class F>
64 RCP<T>& operator=(const std::shared_ptr<F> x)
65 {
66 RCP<T>(x).swap(*this);
67 return *this;
68 }
69
70 // this conversion operator is already implemented for shared_ptr
71 #if 0
72 // template function for implicit conversion ops.
73 template<class NewType>
74 operator RCP<NewType>()
75 {
76 return RCP<NewType>( std::shared_ptr<NewType>(*this) );
77 }
78 #endif
79 };
80
81 // *************************************************************** makeRCP **
82
101 template <class T>
102 RCP<T> makeRCP(T* x)
103 {
104 return RCP<T>(x);
105 }
106
107 // ********************************************************** makeRCP_weak **
108
121 template<class T>
122 RCP<T> makeRCP_weak(T* x)
123 {
124 return RCP<T>(x, null_deleter());
125 }
126
127#if 1
128 template<class T>
129 RCP<const T> makecRCP_weak(T* x) // create a const pointer
130 {
131 return RCP<const T>(x, null_deleter());
132 }
133#endif
134
135
136} // namespace concepts
RCP()
Default constructor.
RCP(F x, G y)
Constructor which includes the deleter G.
RCP< T > makeRCP(T *x)
RCP< T > makeRCP_weak(T *x)
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320