sp_counted_impl.hpp
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
3 #define BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
4 
5 // MS compatible compilers support #pragma once
6 
7 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
8 # pragma once
9 #endif
10 
11 //
12 // detail/sp_counted_impl.hpp
13 //
14 // Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
15 // Copyright 2004-2005 Peter Dimov
16 //
17 // Distributed under the Boost Software License, Version 1.0. (See
18 // accompanying file LICENSE_1_0.txt or copy at
19 // http://www.boost.org/LICENSE_1_0.txt)
20 //
21 
22 #if defined(BOOST_SP_USE_STD_ALLOCATOR) && defined(BOOST_SP_USE_QUICK_ALLOCATOR)
23 # error BOOST_SP_USE_STD_ALLOCATOR and BOOST_SP_USE_QUICK_ALLOCATOR are incompatible.
24 #endif
25 
28 
29 #if defined(BOOST_SP_USE_STD_ALLOCATOR)
30 #include <memory> // std::allocator
31 #endif
32 
33 #include <cstddef> // std::size_t
34 
35 namespace boost
36 {
37 
38 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
39 
40 void sp_scalar_constructor_hook( void * px, std::size_t size, void * pn );
41 void sp_scalar_destructor_hook( void * px, std::size_t size, void * pn );
42 
43 #endif
44 
45 namespace detail
46 {
47 
48 // get_local_deleter
49 
50 template<class D> class local_sp_deleter;
51 
52 template<class D> D * get_local_deleter( D * /*p*/ )
53 {
54  return 0;
55 }
56 
57 template<class D> D * get_local_deleter( local_sp_deleter<D> * p );
58 
59 //
60 
61 template<class X> class sp_counted_impl_p: public sp_counted_base
62 {
63 private:
64 
65  X * px_;
66 
69 
71 
72 public:
73 
74  explicit sp_counted_impl_p( X * px ): px_( px )
75  {
76 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
77  boost::sp_scalar_constructor_hook( px, sizeof(X), this );
78 #endif
79  }
80 
81  virtual void dispose() // nothrow
82  {
83 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
84  boost::sp_scalar_destructor_hook( px_, sizeof(X), this );
85 #endif
87  }
88 
89  virtual void * get_deleter( sp_typeinfo const & )
90  {
91  return 0;
92  }
93 
94  virtual void * get_local_deleter( sp_typeinfo const & )
95  {
96  return 0;
97  }
98 
99  virtual void * get_untyped_deleter()
100  {
101  return 0;
102  }
103 
104 #if defined(BOOST_SP_USE_STD_ALLOCATOR)
105 
106  void * operator new( std::size_t )
107  {
108  return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) );
109  }
110 
111  void operator delete( void * p )
112  {
113  std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 );
114  }
115 
116 #endif
117 
118 #if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
119 
120  void * operator new( std::size_t )
121  {
122  return quick_allocator<this_type>::alloc();
123  }
124 
125  void operator delete( void * p )
126  {
127  quick_allocator<this_type>::dealloc( p );
128  }
129 
130 #endif
131 };
132 
133 //
134 // Borland's Codeguard trips up over the -Vx- option here:
135 //
136 #ifdef __CODEGUARD__
137 # pragma option push -Vx-
138 #endif
139 
140 template<class P, class D> class sp_counted_impl_pd: public sp_counted_base
141 {
142 private:
143 
144  P ptr; // copy constructor must not throw
145  D del; // copy constructor must not throw
146 
149 
151 
152 public:
153 
154  // pre: d(p) must not throw
155 
156  sp_counted_impl_pd( P p, D & d ): ptr( p ), del( d )
157  {
158  }
159 
160  sp_counted_impl_pd( P p ): ptr( p ), del()
161  {
162  }
163 
164  virtual void dispose() // nothrow
165  {
166  del( ptr );
167  }
168 
169  virtual void * get_deleter( sp_typeinfo const & ti )
170  {
171  return ti == BOOST_SP_TYPEID(D)? &reinterpret_cast<char&>( del ): 0;
172  }
173 
174  virtual void * get_local_deleter( sp_typeinfo const & ti )
175  {
176  return ti == BOOST_SP_TYPEID(D)? boost::detail::get_local_deleter( std::addressof( del ) ): 0;
177  }
178 
179  virtual void * get_untyped_deleter()
180  {
181  return &reinterpret_cast<char&>( del );
182  }
183 
184 #if defined(BOOST_SP_USE_STD_ALLOCATOR)
185 
186  void * operator new( std::size_t )
187  {
188  return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) );
189  }
190 
191  void operator delete( void * p )
192  {
193  std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 );
194  }
195 
196 #endif
197 
198 #if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
199 
200  void * operator new( std::size_t )
201  {
202  return quick_allocator<this_type>::alloc();
203  }
204 
205  void operator delete( void * p )
206  {
207  quick_allocator<this_type>::dealloc( p );
208  }
209 
210 #endif
211 };
212 
213 template<class P, class D, class A> class sp_counted_impl_pda: public sp_counted_base
214 {
215 private:
216 
217  P p_; // copy constructor must not throw
218  D d_; // copy constructor must not throw
219  A a_; // copy constructor must not throw
220 
223 
225 
226 public:
227 
228  // pre: d( p ) must not throw
229 
230  sp_counted_impl_pda( P p, D & d, A a ): p_( p ), d_( d ), a_( a )
231  {
232  }
233 
234  sp_counted_impl_pda( P p, A a ): p_( p ), d_( a ), a_( a )
235  {
236  }
237 
238  virtual void dispose() // nothrow
239  {
240  d_( p_ );
241  }
242 
243  virtual void destroy() // nothrow
244  {
245 #if !defined( BOOST_NO_CXX11_ALLOCATOR )
246 
247  typedef typename std::allocator_traits<A>::template rebind_alloc< this_type > A2;
248 
249 #else
250 
251  typedef typename A::template rebind< this_type >::other A2;
252 
253 #endif
254 
255  A2 a2( a_ );
256 
257  this->~this_type();
258 
259  a2.deallocate( this, 1 );
260  }
261 
262  virtual void * get_deleter( sp_typeinfo const & ti )
263  {
264  return ti == BOOST_SP_TYPEID( D )? &reinterpret_cast<char&>( d_ ): 0;
265  }
266 
267  virtual void * get_local_deleter( sp_typeinfo const & ti )
268  {
269  return ti == BOOST_SP_TYPEID(D)? boost::detail::get_local_deleter( std::addressof( d_ ) ): 0;
270  }
271 
272  virtual void * get_untyped_deleter()
273  {
274  return &reinterpret_cast<char&>( d_ );
275  }
276 };
277 
278 #ifdef __CODEGUARD__
279 # pragma option pop
280 #endif
281 
282 } // namespace detail
283 
284 } // namespace boost
285 
286 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
boost::detail::sp_counted_impl_p
Definition: sp_counted_impl.hpp:61
boost::detail::sp_counted_impl_pda::operator=
sp_counted_impl_pda & operator=(sp_counted_impl_pda const &)
boost::detail::sp_counted_impl_pda::this_type
sp_counted_impl_pda< P, D, A > this_type
Definition: sp_counted_impl.hpp:224
boost::detail::sp_counted_impl_pda::p_
P p_
Definition: sp_counted_impl.hpp:217
boost::detail::sp_counted_impl_pda::sp_counted_impl_pda
sp_counted_impl_pda(sp_counted_impl_pda const &)
boost::detail::get_local_deleter
D * get_local_deleter(D *)
Definition: sp_counted_impl.hpp:52
boost::detail::sp_counted_impl_pd::del
D del
Definition: sp_counted_impl.hpp:145
boost::detail::sp_counted_impl_pd::this_type
sp_counted_impl_pd< P, D > this_type
Definition: sp_counted_impl.hpp:150
boost::detail::sp_counted_impl_pd::get_local_deleter
virtual void * get_local_deleter(sp_typeinfo const &ti)
Definition: sp_counted_impl.hpp:174
boost::detail::sp_counted_impl_pda::get_local_deleter
virtual void * get_local_deleter(sp_typeinfo const &ti)
Definition: sp_counted_impl.hpp:267
boost
boost::detail::sp_counted_base
Definition: sp_counted_base_std_atomic.hpp:64
sp_typeinfo
std::type_info sp_typeinfo
Definition: sp_counted_base_std_atomic.hpp:19
boost::detail::sp_counted_impl_p::get_local_deleter
virtual void * get_local_deleter(sp_typeinfo const &)
Definition: sp_counted_impl.hpp:94
boost::detail::sp_counted_impl_p::this_type
sp_counted_impl_p< X > this_type
Definition: sp_counted_impl.hpp:70
sp_counted_base.hpp
std::allocator
Definition: message_forward.h:41
A
boost::detail::sp_counted_impl_pda::a_
A a_
Definition: sp_counted_impl.hpp:219
boost::detail::sp_counted_impl_pd::sp_counted_impl_pd
sp_counted_impl_pd(P p)
Definition: sp_counted_impl.hpp:160
boost::detail::sp_counted_impl_pda::get_untyped_deleter
virtual void * get_untyped_deleter()
Definition: sp_counted_impl.hpp:272
boost::detail::sp_counted_impl_pd
Definition: sp_counted_impl.hpp:140
boost::detail::sp_counted_impl_p::get_untyped_deleter
virtual void * get_untyped_deleter()
Definition: sp_counted_impl.hpp:99
boost::detail::sp_counted_impl_p::get_deleter
virtual void * get_deleter(sp_typeinfo const &)
Definition: sp_counted_impl.hpp:89
boost::detail::sp_counted_impl_pd::get_untyped_deleter
virtual void * get_untyped_deleter()
Definition: sp_counted_impl.hpp:179
boost::detail::local_sp_deleter
Definition: sp_counted_impl.hpp:50
boost::detail::sp_counted_impl_pd::operator=
sp_counted_impl_pd & operator=(sp_counted_impl_pd const &)
d
d
boost::detail::sp_counted_impl_pd::ptr
P ptr
Definition: sp_counted_impl.hpp:144
boost::detail::sp_counted_impl_pd::get_deleter
virtual void * get_deleter(sp_typeinfo const &ti)
Definition: sp_counted_impl.hpp:169
boost::detail::sp_counted_impl_pda::destroy
virtual void destroy()
Definition: sp_counted_impl.hpp:243
boost::detail::sp_counted_impl_pda::dispose
virtual void dispose()
Definition: sp_counted_impl.hpp:238
boost::detail::sp_counted_impl_p::sp_counted_impl_p
sp_counted_impl_p(sp_counted_impl_p const &)
boost::detail::sp_counted_impl_pda::get_deleter
virtual void * get_deleter(sp_typeinfo const &ti)
Definition: sp_counted_impl.hpp:262
boost::detail::sp_counted_impl_p::sp_counted_impl_p
sp_counted_impl_p(X *px)
Definition: sp_counted_impl.hpp:74
boost::detail::sp_counted_impl_pda::d_
D d_
Definition: sp_counted_impl.hpp:218
boost::detail::sp_counted_impl_p::operator=
sp_counted_impl_p & operator=(sp_counted_impl_p const &)
boost::detail::sp_counted_impl_pda::sp_counted_impl_pda
sp_counted_impl_pda(P p, D &d, A a)
Definition: sp_counted_impl.hpp:230
boost::checked_delete
void checked_delete(T *x)
Definition: checked_delete.hpp:29
sick_scan_base.h
boost::detail::sp_counted_impl_pd::sp_counted_impl_pd
sp_counted_impl_pd(sp_counted_impl_pd const &)
boost::detail::sp_counted_impl_pd::sp_counted_impl_pd
sp_counted_impl_pd(P p, D &d)
Definition: sp_counted_impl.hpp:156
BOOST_SP_TYPEID
#define BOOST_SP_TYPEID(T)
Definition: sp_counted_base_std_atomic.hpp:21
boost::detail::sp_counted_impl_pd::dispose
virtual void dispose()
Definition: sp_counted_impl.hpp:164
boost::detail::sp_counted_impl_pda::sp_counted_impl_pda
sp_counted_impl_pda(P p, A a)
Definition: sp_counted_impl.hpp:234
boost::detail::sp_counted_impl_p::px_
X * px_
Definition: sp_counted_impl.hpp:65
boost::detail::sp_counted_impl_pda
Definition: sp_counted_impl.hpp:213
boost::detail::sp_counted_impl_p::dispose
virtual void dispose()
Definition: sp_counted_impl.hpp:81
checked_delete.hpp


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:12