5 #ifndef DUNE_SHARED_PTR_HH
6 #define DUNE_SHARED_PTR_HH
8 #if defined SHARED_PTR_HEADER
9 # include SHARED_PTR_HEADER
11 #if defined HAVE_BOOST_SHARED_PTR_HPP
12 #if defined HAVE_BOOST_MAKE_SHARED_HPP
13 # include <boost/make_shared.hpp>
28 #ifdef SHARED_PTR_NAMESPACE
29 using SHARED_PTR_NAMESPACE :: shared_ptr;
106 template<
class T1,
class Deleter>
107 inline shared_ptr(T1 * pointer, Deleter deleter);
152 operator bool()
const {
153 return count_ != 0 && rep_ != 0;
166 inline void reset(T1* pointer);
169 template<
class T1,
class Deleter>
170 inline void reset(T1* pointer, Deleter deleter);
180 template<
class Deleter>
181 class SharedCountImpl :
187 SharedCountImpl(T* elem,
const Deleter& deleter) :
193 SharedCountImpl(
const SharedCountImpl& rep)
194 : SharedCount(rep), deleter_(rep.deleter_), rep_(rep.rep_) {}
205 struct DefaultDeleter
216 typedef T* *__unspecified_bool_type;
222 return rep_ == 0 ? 0 : &shared_ptr::rep_;
232 count_ =
new SharedCountImpl<DefaultDeleter>(p, DefaultDeleter());
243 template<
class T1,
class Deleter>
247 count_ =
new SharedCountImpl<Deleter>(p, deleter);
260 : count_(other.count_), rep_(other.rep_)
268 : count_(other.count_), rep_(other.rep_)
278 return assign(other);
284 return assign(other);
294 if(rep_!=0 && --(count_->count_)<=0) {
299 count_ = other.count_;
306 if(rep_!=0 && --(count_->count_)==0) {
339 return count_->count_;
347 other.count_ = dummy;
367 template<
class T1,
class Deleter>
374 #endif // #ifdef SHARED_PTR_NAMESPACE
381 #ifdef SHARED_PTR_NAMESPACE
392 template<
typename T,
typename Arg1>
398 template<
typename T,
typename Arg1,
typename Arg2>
404 template<
typename T,
typename Arg1,
typename Arg2,
typename Arg3>
410 template<
typename T,
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
416 template<
typename T,
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4,
424 template<
typename T,
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4,
425 typename Arg5,
typename Arg6>
427 const Arg5& arg5,
const Arg6& arg6)
432 template<
typename T,
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4,
433 typename Arg5,
typename Arg6,
typename Arg7>
435 const Arg5& arg5,
const Arg6& arg6,
const Arg7& arg7)
437 return shared_ptr<T>(
new T(arg1,arg2,arg3,arg4,arg5,arg6,arg7));
440 template<
typename T,
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4,
441 typename Arg5,
typename Arg6,
typename Arg7,
typename Arg8>
443 const Arg5& arg5,
const Arg6& arg6,
const Arg7& arg7,
const Arg8& arg8)
445 return shared_ptr<T>(
new T(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8));
448 template<
typename T,
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4,
449 typename Arg5,
typename Arg6,
typename Arg7,
typename Arg8,
typename Arg9>
451 const Arg5& arg5,
const Arg6& arg6,
const Arg7& arg7,
const Arg8& arg8,
454 return shared_ptr<T>(
new T(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9));
457 #endif // custom make_shared
520 template<
typename T,
typename T2>