shared_count(P p, D d, void const * = 0): pi_(0)
+ {
+#ifndef BOOST_NO_EXCEPTIONS
+
+ try
+ {
+ pi_ = new counted_base_impl(p, d, 1, 1);
+ }
+ catch(...)
+ {
+ d(p); // delete p
+ throw;
+ }
+
+#else
+
+ pi_ = new counted_base_impl
(p, d, 1, 1);
+
+ if(pi_ == 0)
+ {
+ d(p); // delete p
+ boost::throw_exception(std::bad_alloc());
+ }
+
+#endif
+ }
+
+ template shared_count(P, D, counted_base * pi): pi_(pi)
+ {
+ pi_->add_ref();
+ }
+
+#ifndef BOOST_NO_AUTO_PTR
+
+ // auto_ptr is special cased to provide the strong guarantee
+
+ template
+ explicit shared_count(std::auto_ptr & r): pi_(new counted_base_impl< Y *, checked_deleter >(r.get(), checked_deleter(), 1, 1))
+ {
+ r.release();
+ }
+
+#endif
+
+ ~shared_count() // nothrow
+ {
+ pi_->release();
+ }
+
+ shared_count(shared_count const & r): pi_(r.pi_) // nothrow
+ {
+ pi_->add_ref();
+ }
+
+ explicit shared_count(weak_count const & r); // throws use_count_is_zero when r.use_count() == 0
+
+ shared_count & operator= (shared_count const & r) // nothrow
+ {
+ counted_base * tmp = r.pi_;
+ tmp->add_ref();
+ pi_->release();
+ pi_ = tmp;
+
+ return *this;
+ }
+
+ void swap(shared_count & r) // nothrow
+ {
+ counted_base * tmp = r.pi_;
+ r.pi_ = pi_;
+ pi_ = tmp;
+ }
+
+ long use_count() const // nothrow
+ {
+ return pi_->use_count();
+ }
+
+ bool unique() const // nothrow
+ {
+ return pi_->use_count() == 1;
+ }
+
+ friend inline bool operator==(shared_count const & a, shared_count const & b)
+ {
+ return a.pi_ == b.pi_;
+ }
+
+ friend inline bool operator<(shared_count const & a, shared_count const & b)
+ {
+ return std::less()(a.pi_, b.pi_);
+ }
+};
+
+#ifdef __CODEGUARD__
+#pragma option pop
+#endif
+
+
+class weak_count
+{
+private:
+
+ counted_base * pi_;
+
+ friend class shared_count;
+
+public:
+
+ weak_count(): pi_(new counted_base(0, 1)) // can throw
+ {
+ }
+
+ weak_count(shared_count const & r): pi_(r.pi_) // nothrow
+ {
+ pi_->weak_add_ref();
+ }
+
+ weak_count(weak_count const & r): pi_(r.pi_) // nothrow
+ {
+ pi_->weak_add_ref();
+ }
+
+ ~weak_count() // nothrow
+ {
+ pi_->weak_release();
+ }
+
+ weak_count & operator= (shared_count const & r) // nothrow
+ {
+ counted_base * tmp = r.pi_;
+ tmp->weak_add_ref();
+ pi_->weak_release();
+ pi_ = tmp;
+
+ return *this;
+ }
+
+ weak_count & operator= (weak_count const & r) // nothrow
+ {
+ counted_base * tmp = r.pi_;
+ tmp->weak_add_ref();
+ pi_->weak_release();
+ pi_ = tmp;
+
+ return *this;
+ }
+
+ void swap(weak_count & r) // nothrow
+ {
+ counted_base * tmp = r.pi_;
+ r.pi_ = pi_;
+ pi_ = tmp;
+ }
+
+ long use_count() const // nothrow
+ {
+ return pi_->use_count();
+ }
+
+ friend inline bool operator==(weak_count const & a, weak_count const & b)
+ {
+ return a.pi_ == b.pi_;
+ }
+
+ friend inline bool operator<(weak_count const & a, weak_count const & b)
+ {
+ return std::less()(a.pi_, b.pi_);
+ }
+};
+
+inline shared_count::shared_count(weak_count const & r): pi_(r.pi_)
+{
+ pi_->add_ref();
+}
+
+} // namespace detail
+
+} // namespace boost
+
+#ifdef __BORLANDC__
+# pragma warn .8027 // Functions containing try are not expanded inline
+# pragma warn .8026 // Functions with excep. spec. are not expanded inline
+#endif
+
+#endif // #ifndef BOOST_DETAIL_SHARED_COUNT_HPP_INCLUDED
diff --git a/include/boost/detail/shared_ptr_nmt.hpp b/include/boost/detail/shared_ptr_nmt.hpp
new file mode 100644
index 0000000..14fbe65
--- /dev/null
+++ b/include/boost/detail/shared_ptr_nmt.hpp
@@ -0,0 +1,183 @@
+#ifndef BOOST_DETAIL_SHARED_PTR_NMT_HPP_INCLUDED
+#define BOOST_DETAIL_SHARED_PTR_NMT_HPP_INCLUDED
+
+//
+// detail/shared_ptr_nmt.hpp - shared_ptr.hpp without member templates
+//
+// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+// Copyright (c) 2001, 2002 Peter Dimov
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+// See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation.
+//
+
+#include
+#include
+#include
+#include
+
+#ifndef BOOST_NO_AUTO_PTR
+# include // for std::auto_ptr
+#endif
+
+#include // for std::swap
+#include // for std::less
+#include // for std::bad_alloc
+
+namespace boost
+{
+
+template class shared_ptr
+{
+private:
+
+ typedef detail::atomic_count count_type;
+
+public:
+
+ typedef T element_type;
+ typedef T value_type;
+
+ explicit shared_ptr(T * p = 0): px(p)
+ {
+#ifndef BOOST_NO_EXCEPTIONS
+
+ try // prevent leak if new throws
+ {
+ pn = new count_type(1);
+ }
+ catch(...)
+ {
+ boost::checked_delete(p);
+ throw;
+ }
+
+#else
+
+ pn = new count_type(1);
+
+ if(pn == 0)
+ {
+ boost::checked_delete(p);
+ boost::throw_exception(std::bad_alloc());
+ }
+
+#endif
+ }
+
+ ~shared_ptr()
+ {
+ if(--*pn == 0)
+ {
+ boost::checked_delete(px);
+ delete pn;
+ }
+ }
+
+ shared_ptr(shared_ptr const & r): px(r.px) // never throws
+ {
+ pn = r.pn;
+ ++*pn;
+ }
+
+ shared_ptr & operator=(shared_ptr const & r)
+ {
+ shared_ptr(r).swap(*this);
+ return *this;
+ }
+
+#ifndef BOOST_NO_AUTO_PTR
+
+ explicit shared_ptr(std::auto_ptr & r)
+ {
+ pn = new count_type(1); // may throw
+ px = r.release(); // fix: moved here to stop leak if new throws
+ }
+
+ shared_ptr & operator=(std::auto_ptr & r)
+ {
+ shared_ptr(r).swap(*this);
+ return *this;
+ }
+
+#endif
+
+ void reset(T * p = 0)
+ {
+ BOOST_ASSERT(p == 0 || p != px);
+ shared_ptr(p).swap(*this);
+ }
+
+ T & operator*() const // never throws
+ {
+ BOOST_ASSERT(px != 0);
+ return *px;
+ }
+
+ T * operator->() const // never throws
+ {
+ BOOST_ASSERT(px != 0);
+ return px;
+ }
+
+ T * get() const // never throws
+ {
+ return px;
+ }
+
+ long use_count() const // never throws
+ {
+ return *pn;
+ }
+
+ bool unique() const // never throws
+ {
+ return *pn == 1;
+ }
+
+ void swap(shared_ptr & other) // never throws
+ {
+ std::swap(px, other.px);
+ std::swap(pn, other.pn);
+ }
+
+private:
+
+ T * px; // contained pointer
+ count_type * pn; // ptr to reference counter
+};
+
+template inline bool operator==(shared_ptr const & a, shared_ptr const & b)
+{
+ return a.get() == b.get();
+}
+
+template inline bool operator!=(shared_ptr const & a, shared_ptr const & b)
+{
+ return a.get() != b.get();
+}
+
+template inline bool operator<(shared_ptr const & a, shared_ptr const & b)
+{
+ return std::less()(a.get(), b.get());
+}
+
+template void swap(shared_ptr & a, shared_ptr & b)
+{
+ a.swap(b);
+}
+
+// get_pointer() enables boost::mem_fn to recognize shared_ptr
+
+template inline T * get_pointer(shared_ptr const & p)
+{
+ return p.get();
+}
+
+} // namespace boost
+
+#endif // #ifndef BOOST_DETAIL_SHARED_PTR_NMT_HPP_INCLUDED
diff --git a/include/boost/detail/winapi.hpp b/include/boost/detail/winapi.hpp
new file mode 100644
index 0000000..340036a
--- /dev/null
+++ b/include/boost/detail/winapi.hpp
@@ -0,0 +1,106 @@
+#ifndef BOOST_DETAIL_WINAPI_HPP_INCLUDED
+#define BOOST_DETAIL_WINAPI_HPP_INCLUDED
+
+#if _MSC_VER >= 1020
+#pragma once
+#endif
+
+//
+// boost/detail/winapi.hpp - a lightweight version of
+//
+// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+namespace boost
+{
+
+namespace detail
+{
+
+namespace winapi
+{
+
+typedef long long_type;
+typedef unsigned long dword_type;
+typedef void * handle_type;
+
+#if defined(_WIN64)
+
+typedef __int64 int_ptr_type;
+typedef unsigned __int64 uint_ptr_type;
+typedef __int64 long_ptr_type;
+typedef unsigned __int64 ulong_ptr_type;
+
+#else
+
+typedef int int_ptr_type;
+typedef unsigned int uint_ptr_type;
+typedef long long_ptr_type;
+typedef unsigned long ulong_ptr_type;
+
+#endif
+
+struct critical_section
+{
+ struct critical_section_debug * DebugInfo;
+ long_type LockCount;
+ long_type RecursionCount;
+ handle_type OwningThread;
+ handle_type LockSemaphore;
+ ulong_ptr_type SpinCount;
+};
+
+#if defined(_WIN64)
+
+// Intel 6.0 on Win64 version, posted by Tim Fenders to [boost-users]
+
+extern "C" long_type __cdecl _InterlockedIncrement(long_type volatile *);
+extern "C" long_type __cdecl _InterlockedDecrement(long_type volatile *);
+extern "C" long_type __cdecl _InterlockedExchange(long_type volatile *, long_type);
+
+#pragma intrinsic(_InterlockedIncrement)
+#pragma intrinsic(_InterlockedDecrement)
+#pragma intrinsic(_InterlockedExchange)
+
+inline long_type InterlockedIncrement(long_type volatile * lp)
+{
+ return _InterlockedIncrement(lp);
+}
+
+inline long_type InterlockedDecrement(long_type volatile* lp)
+{
+ return _InterlockedDecrement(lp);
+}
+
+inline long_type InterlockedExchange(long_type volatile* lp, long_type l)
+{
+ return _InterlockedExchange(lp, l);
+}
+
+#else
+
+extern "C" __declspec(dllimport) long_type __stdcall InterlockedIncrement(long_type volatile *);
+extern "C" __declspec(dllimport) long_type __stdcall InterlockedDecrement(long_type volatile *);
+extern "C" __declspec(dllimport) long_type __stdcall InterlockedExchange(long_type volatile *, long_type);
+
+#endif
+
+extern "C" __declspec(dllimport) void __stdcall Sleep(dword_type);
+
+extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(critical_section *);
+extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(critical_section *);
+extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(critical_section *);
+extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(critical_section *);
+
+} // namespace winapi
+
+} // namespace detail
+
+} // namespace boost
+
+#endif // #ifndef BOOST_DETAIL_WINAPI_HPP_INCLUDED
diff --git a/include/boost/intrusive_ptr.hpp b/include/boost/intrusive_ptr.hpp
new file mode 100644
index 0000000..4ada734
--- /dev/null
+++ b/include/boost/intrusive_ptr.hpp
@@ -0,0 +1,202 @@
+#ifndef BOOST_INTRUSIVE_PTR_HPP_INCLUDED
+#define BOOST_INTRUSIVE_PTR_HPP_INCLUDED
+
+//
+// intrusive_ptr.hpp
+//
+// Copyright (c) 2001, 2002 Peter Dimov
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+// See http://www.boost.org/libs/smart_ptr/intrusive_ptr.html for documentation.
+//
+
+#ifdef BOOST_MSVC // moved here to work around VC++ compiler crash
+# pragma warning(push)
+# pragma warning(disable:4284) // odd return type for operator->
+#endif
+
+#include // std::less
+
+namespace boost
+{
+
+//
+// intrusive_ptr
+//
+// A smart pointer that uses intrusive reference counting.
+//
+// Relies on unqualified calls to
+//
+// void intrusive_ptr_add_ref(T * p);
+// void intrusive_ptr_release(T * p);
+//
+// (p != 0)
+//
+// The object is responsible for destroying itself.
+//
+
+template class intrusive_ptr
+{
+private:
+
+ typedef intrusive_ptr this_type;
+
+public:
+
+ intrusive_ptr(): p_(0)
+ {
+ }
+
+ intrusive_ptr(T * p): p_(p)
+ {
+ if(p_ != 0) intrusive_ptr_add_ref(p_);
+ }
+
+ ~intrusive_ptr()
+ {
+ if(p_ != 0) intrusive_ptr_release(p_);
+ }
+
+#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES)
+
+ template intrusive_ptr(intrusive_ptr const & rhs): p_(rhs.get())
+ {
+ if(p_ != 0) intrusive_ptr_add_ref(p_);
+ }
+
+#endif
+
+ intrusive_ptr(intrusive_ptr const & rhs): p_(rhs.p_)
+ {
+ if(p_ != 0) intrusive_ptr_add_ref(p_);
+ }
+
+#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES)
+
+ template intrusive_ptr & operator=(intrusive_ptr const & rhs)
+ {
+ this_type(rhs).swap(*this);
+ return *this;
+ }
+
+#endif
+
+ intrusive_ptr & operator=(intrusive_ptr const & rhs)
+ {
+ this_type(rhs).swap(*this);
+ return *this;
+ }
+
+ intrusive_ptr & operator=(T * rhs)
+ {
+ this_type(rhs).swap(*this);
+ return *this;
+ }
+
+ void swap(intrusive_ptr & rhs)
+ {
+ T * tmp = p_;
+ p_ = rhs.p_;
+ rhs.p_ = tmp;
+ }
+
+ T * get() const
+ {
+ return p_;
+ }
+
+ T & operator*() const
+ {
+ return *p_;
+ }
+
+ T * operator->() const
+ {
+ return p_;
+ }
+
+ bool empty() const
+ {
+ return p_ == 0;
+ }
+
+ typedef bool (intrusive_ptr::*bool_type) () const;
+
+ operator bool_type () const
+ {
+ return p_ == 0? 0: &intrusive_ptr::empty;
+ }
+
+private:
+
+ T * p_;
+};
+
+template void swap(intrusive_ptr & lhs, intrusive_ptr & rhs)
+{
+ lhs.swap(rhs);
+}
+
+template intrusive_ptr shared_dynamic_cast(intrusive_ptr const & p)
+{
+ return dynamic_cast(p.get());
+}
+
+template intrusive_ptr shared_static_cast(intrusive_ptr const & p)
+{
+ return static_cast(p.get());
+}
+
+template inline bool operator==(intrusive_ptr const & a, intrusive_ptr const & b)
+{
+ return a.get() == b.get();
+}
+
+template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b)
+{
+ return a.get() != b.get();
+}
+
+template inline bool operator<(intrusive_ptr const & a, intrusive_ptr const & b)
+{
+ return std::less(a.get(), b.get());
+}
+
+template inline bool operator==(intrusive_ptr const & a, T * b)
+{
+ return a.get() == b;
+}
+
+template inline bool operator!=(intrusive_ptr const & a, T * b)
+{
+ return a.get() != b;
+}
+
+template inline bool operator==(T * a, intrusive_ptr const & b)
+{
+ return a == b.get();
+}
+
+template inline bool operator!=(T * a, intrusive_ptr const & b)
+{
+ return a != b.get();
+}
+
+// mem_fn support
+
+template T * get_pointer(intrusive_ptr const & p)
+{
+ return p.get();
+}
+
+} // namespace boost
+
+#ifdef BOOST_MSVC
+# pragma warning(pop)
+#endif
+
+#endif // #ifndef BOOST_INTRUSIVE_PTR_HPP_INCLUDED
diff --git a/include/boost/scoped_array.hpp b/include/boost/scoped_array.hpp
new file mode 100644
index 0000000..8c7fdcc
--- /dev/null
+++ b/include/boost/scoped_array.hpp
@@ -0,0 +1,102 @@
+#ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED
+#define BOOST_SCOPED_ARRAY_HPP_INCLUDED
+
+// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+// Copyright (c) 2001, 2002 Peter Dimov
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+// See http://www.boost.org/libs/smart_ptr/scoped_array.htm for documentation.
+//
+
+#include
+#include
+#include // in case ptrdiff_t not in std
+#include // for std::ptrdiff_t
+
+namespace boost
+{
+
+// scoped_array extends scoped_ptr to arrays. Deletion of the array pointed to
+// is guaranteed, either on destruction of the scoped_array or via an explicit
+// reset(). Use shared_array or std::vector if your needs are more complex.
+
+template class scoped_array // noncopyable
+{
+private:
+
+ T * ptr;
+
+ scoped_array(scoped_array const &);
+ scoped_array & operator=(scoped_array const &);
+
+ typedef scoped_array this_type;
+
+public:
+
+ typedef T element_type;
+
+ explicit scoped_array(T * p = 0) : ptr(p) // never throws
+ {
+ }
+
+ ~scoped_array() // never throws
+ {
+ checked_array_delete(ptr);
+ }
+
+ void reset(T * p = 0) // never throws
+ {
+ if (ptr != p)
+ {
+ checked_array_delete(ptr);
+ ptr = p;
+ }
+ }
+
+ T & operator[](std::ptrdiff_t i) const // never throws
+ {
+ BOOST_ASSERT(ptr != 0);
+ BOOST_ASSERT(i >= 0);
+ return ptr[i];
+ }
+
+ T * get() const // never throws
+ {
+ return ptr;
+ }
+
+ // implicit conversion to "bool"
+
+ typedef T * (this_type::*unspecified_bool_type)() const;
+
+ operator unspecified_bool_type() const // never throws
+ {
+ return ptr == 0? 0: &this_type::get;
+ }
+
+ bool operator! () const // never throws
+ {
+ return ptr == 0;
+ }
+
+ void swap(scoped_array & b) // never throws
+ {
+ T * tmp = b.ptr;
+ b.ptr = ptr;
+ ptr = tmp;
+ }
+
+};
+
+template inline void swap(scoped_array & a, scoped_array & b) // never throws
+{
+ a.swap(b);
+}
+
+} // namespace boost
+
+#endif // #ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED
diff --git a/include/boost/scoped_ptr.hpp b/include/boost/scoped_ptr.hpp
new file mode 100644
index 0000000..589bd36
--- /dev/null
+++ b/include/boost/scoped_ptr.hpp
@@ -0,0 +1,123 @@
+#ifndef BOOST_SCOPED_PTR_HPP_INCLUDED
+#define BOOST_SCOPED_PTR_HPP_INCLUDED
+
+// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+// Copyright (c) 2001, 2002 Peter Dimov
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+// See http://www.boost.org/libs/smart_ptr/scoped_ptr.htm for documentation.
+//
+
+#include
+#include
+
+#ifndef BOOST_NO_AUTO_PTR
+# include // for std::auto_ptr
+#endif
+
+namespace boost
+{
+
+// scoped_ptr mimics a built-in pointer except that it guarantees deletion
+// of the object pointed to, either on destruction of the scoped_ptr or via
+// an explicit reset(). scoped_ptr is a simple solution for simple needs;
+// use shared_ptr or std::auto_ptr if your needs are more complex.
+
+template class scoped_ptr // noncopyable
+{
+private:
+
+ T * ptr;
+
+ scoped_ptr(scoped_ptr const &);
+ scoped_ptr & operator=(scoped_ptr const &);
+
+ typedef scoped_ptr this_type;
+
+public:
+
+ typedef T element_type;
+
+ explicit scoped_ptr(T * p = 0): ptr(p) // never throws
+ {
+ }
+
+#ifndef BOOST_NO_AUTO_PTR
+
+ explicit scoped_ptr(std::auto_ptr p): ptr(p.release()) // never throws
+ {
+ }
+
+#endif
+
+ ~scoped_ptr() // never throws
+ {
+ checked_delete(ptr);
+ }
+
+ void reset(T * p = 0) // never throws
+ {
+ if(ptr != p)
+ {
+ this_type(p).swap(*this);
+ }
+ }
+
+ T & operator*() const // never throws
+ {
+ BOOST_ASSERT(ptr != 0);
+ return *ptr;
+ }
+
+ T * operator->() const // never throws
+ {
+ BOOST_ASSERT(ptr != 0);
+ return ptr;
+ }
+
+ T * get() const // never throws
+ {
+ return ptr;
+ }
+
+ // implicit conversion to "bool"
+
+ typedef T * (this_type::*unspecified_bool_type)() const;
+
+ operator unspecified_bool_type() const // never throws
+ {
+ return ptr == 0? 0: &this_type::get;
+ }
+
+ bool operator! () const // never throws
+ {
+ return ptr == 0;
+ }
+
+ void swap(scoped_ptr & b) // never throws
+ {
+ T * tmp = b.ptr;
+ b.ptr = ptr;
+ ptr = tmp;
+ }
+};
+
+template inline void swap(scoped_ptr & a, scoped_ptr & b) // never throws
+{
+ a.swap(b);
+}
+
+// get_pointer(p) is a generic way to say p.get()
+
+template inline T * get_pointer(scoped_ptr const & p)
+{
+ return p.get();
+}
+
+} // namespace boost
+
+#endif // #ifndef BOOST_SCOPED_PTR_HPP_INCLUDED
diff --git a/include/boost/shared_array.hpp b/include/boost/shared_array.hpp
new file mode 100644
index 0000000..c60a85a
--- /dev/null
+++ b/include/boost/shared_array.hpp
@@ -0,0 +1,156 @@
+#ifndef BOOST_SHARED_ARRAY_HPP_INCLUDED
+#define BOOST_SHARED_ARRAY_HPP_INCLUDED
+
+//
+// shared_array.hpp
+//
+// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+// Copyright (c) 2001, 2002 Peter Dimov
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+// See http://www.boost.org/libs/smart_ptr/shared_array.htm for documentation.
+//
+
+#include // for broken compiler workarounds
+
+#if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
+#include
+#else
+
+#include
+#include
+
+#include
+
+#include // for std::ptrdiff_t
+#include // for std::swap
+#include // for std::less
+
+namespace boost
+{
+
+//
+// shared_array
+//
+// shared_array extends shared_ptr to arrays.
+// The array pointed to is deleted when the last shared_array pointing to it
+// is destroyed or reset.
+//
+
+template class shared_array
+{
+private:
+
+ // Borland 5.5.1 specific workarounds
+ typedef checked_array_deleter deleter;
+ typedef shared_array this_type;
+
+public:
+
+ typedef T element_type;
+
+ explicit shared_array(T * p = 0): px(p), pn(p, deleter())
+ {
+ }
+
+ //
+ // Requirements: D's copy constructor must not throw
+ //
+ // shared_array will release p by calling d(p)
+ //
+
+ template shared_array(T * p, D d): px(p), pn(p, d)
+ {
+ }
+
+// generated copy constructor, assignment, destructor are fine
+
+ void reset(T * p = 0)
+ {
+ BOOST_ASSERT(p == 0 || p != px);
+ this_type(p).swap(*this);
+ }
+
+ template void reset(T * p, D d)
+ {
+ this_type(p, d).swap(*this);
+ }
+
+ T & operator[] (std::ptrdiff_t i) const // never throws
+ {
+ BOOST_ASSERT(px != 0);
+ BOOST_ASSERT(i >= 0);
+ return px[i];
+ }
+
+ T * get() const // never throws
+ {
+ return px;
+ }
+
+ // implicit conversion to "bool"
+
+ typedef T * (this_type::*unspecified_bool_type)() const;
+
+ operator unspecified_bool_type() const // never throws
+ {
+ return px == 0? 0: &this_type::get;
+ }
+
+ bool operator! () const // never throws
+ {
+ return px == 0;
+ }
+
+ bool unique() const // never throws
+ {
+ return pn.unique();
+ }
+
+ long use_count() const // never throws
+ {
+ return pn.use_count();
+ }
+
+ void swap(shared_array & other) // never throws
+ {
+ std::swap(px, other.px);
+ pn.swap(other.pn);
+ }
+
+private:
+
+ T * px; // contained pointer
+ detail::shared_count pn; // reference counter
+
+}; // shared_array
+
+template inline bool operator==(shared_array const & a, shared_array const & b) // never throws
+{
+ return a.get() == b.get();
+}
+
+template inline bool operator!=(shared_array const & a, shared_array const & b) // never throws
+{
+ return a.get() != b.get();
+}
+
+template inline bool operator<(shared_array const & a, shared_array const & b) // never throws
+{
+ return std::less()(a.get(), b.get());
+}
+
+template void swap(shared_array & a, shared_array & b) // never throws
+{
+ a.swap(b);
+}
+
+} // namespace boost
+
+#endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
+
+#endif // #ifndef BOOST_SHARED_ARRAY_HPP_INCLUDED
diff --git a/include/boost/shared_ptr.hpp b/include/boost/shared_ptr.hpp
new file mode 100644
index 0000000..8f55948
--- /dev/null
+++ b/include/boost/shared_ptr.hpp
@@ -0,0 +1,356 @@
+#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
+#define BOOST_SHARED_PTR_HPP_INCLUDED
+
+//
+// shared_ptr.hpp
+//
+// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+// Copyright (c) 2001, 2002 Peter Dimov
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+// See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation.
+//
+
+#include // for broken compiler workarounds
+
+#if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
+#include
+#else
+
+#include
+#include
+#include
+#include
+
+#include // for std::auto_ptr
+#include // for std::swap
+#include // for std::less
+#include // for std::bad_cast
+
+#ifdef BOOST_MSVC // moved here to work around VC++ compiler crash
+# pragma warning(push)
+# pragma warning(disable:4284) // odd return type for operator->
+#endif
+
+namespace boost
+{
+
+namespace detail
+{
+
+struct static_cast_tag {};
+struct dynamic_cast_tag {};
+struct polymorphic_cast_tag {};
+
+template struct shared_ptr_traits
+{
+ typedef T & reference;
+};
+
+template<> struct shared_ptr_traits
+{
+ typedef void reference;
+};
+
+#if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS)
+
+template<> struct shared_ptr_traits
+{
+ typedef void reference;
+};
+
+#endif
+
+} // namespace detail
+
+
+//
+// shared_ptr
+//
+// An enhanced relative of scoped_ptr with reference counted copy semantics.
+// The object pointed to is deleted when the last shared_ptr pointing to it
+// is destroyed or reset.
+//
+
+template class weak_ptr;
+template class intrusive_ptr;
+
+template class shared_ptr
+{
+private:
+
+ // Borland 5.5.1 specific workarounds
+// typedef checked_deleter deleter;
+ typedef shared_ptr this_type;
+
+public:
+
+ typedef T element_type;
+ typedef T value_type;
+
+ shared_ptr(): px(0), pn()
+ {
+ }
+
+ template
+ explicit shared_ptr(Y * p): px(p), pn(p, checked_deleter(), p) // Y must be complete
+ {
+ }
+
+ //
+ // Requirements: D's copy constructor must not throw
+ //
+ // shared_ptr will release p by calling d(p)
+ //
+
+ template shared_ptr(Y * p, D d): px(p), pn(p, d)
+ {
+ }
+
+// generated copy constructor, assignment, destructor are fine
+
+ template
+ explicit shared_ptr(weak_ptr const & r): px(r.px), pn(r.pn) // may throw
+ {
+ }
+
+ template
+ shared_ptr(shared_ptr const & r): px(r.px), pn(r.pn) // never throws
+ {
+ }
+
+ template
+ shared_ptr(intrusive_ptr const & r): px(r.get()), pn(r.get()) // never throws
+ {
+ }
+
+ template
+ shared_ptr(shared_ptr const & r, detail::static_cast_tag): px(static_cast(r.px)), pn(r.pn)
+ {
+ }
+
+ template
+ shared_ptr(shared_ptr const & r, detail::dynamic_cast_tag): px(dynamic_cast(r.px)), pn(r.pn)
+ {
+ if (px == 0) // need to allocate new counter -- the cast failed
+ {
+ pn = detail::shared_count();
+ }
+ }
+
+ template
+ shared_ptr(shared_ptr const & r, detail::polymorphic_cast_tag): px(dynamic_cast(r.px)), pn(r.pn)
+ {
+ if (px == 0)
+ {
+ boost::throw_exception(std::bad_cast());
+ }
+ }
+
+#ifndef BOOST_NO_AUTO_PTR
+
+ template
+ explicit shared_ptr(std::auto_ptr & r): px(r.get()), pn(r)
+ {
+ }
+
+#endif
+
+#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200)
+
+ template
+ shared_ptr & operator=(shared_ptr const & r) // never throws
+ {
+ px = r.px;
+ pn = r.pn; // shared_count::op= doesn't throw
+ return *this;
+ }
+
+#endif
+
+#ifndef BOOST_NO_AUTO_PTR
+
+ template
+ shared_ptr & operator=(std::auto_ptr & r)
+ {
+ this_type(r).swap(*this);
+ return *this;
+ }
+
+#endif
+
+ void reset()
+ {
+ this_type().swap(*this);
+ }
+
+ template void reset(Y * p) // Y must be complete
+ {
+ BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors
+ this_type(p).swap(*this);
+ }
+
+ template void reset(Y * p, D d)
+ {
+ this_type(p, d).swap(*this);
+ }
+
+ typename detail::shared_ptr_traits::reference operator* () const // never throws
+ {
+ BOOST_ASSERT(px != 0);
+ return *px;
+ }
+
+ T * operator-> () const // never throws
+ {
+ BOOST_ASSERT(px != 0);
+ return px;
+ }
+
+ T * get() const // never throws
+ {
+ return px;
+ }
+
+ // implicit conversion to "bool"
+
+ typedef T * (this_type::*unspecified_bool_type)() const;
+
+ operator unspecified_bool_type() const // never throws
+ {
+ return px == 0? 0: &this_type::get;
+ }
+
+ bool operator! () const // never throws
+ {
+ return px == 0;
+ }
+
+ bool unique() const // never throws
+ {
+ return pn.unique();
+ }
+
+ long use_count() const // never throws
+ {
+ return pn.use_count();
+ }
+
+ void swap(shared_ptr & other) // never throws
+ {
+ std::swap(px, other.px);
+ pn.swap(other.pn);
+ }
+
+// Tasteless as this may seem, making all members public allows member templates
+// to work in the absence of member template friends. (Matthew Langston)
+
+#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
+
+private:
+
+ template friend class shared_ptr;
+ template friend class weak_ptr;
+
+
+#endif
+
+ T * px; // contained pointer
+ detail::shared_count pn; // reference counter
+
+}; // shared_ptr
+
+template inline bool operator==(shared_ptr const & a, shared_ptr const & b)
+{
+ return a.get() == b.get();
+}
+
+template inline bool operator!=(shared_ptr const & a, shared_ptr const & b)
+{
+ return a.get() != b.get();
+}
+
+#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96
+
+// Resolve the ambiguity between our op!= and the one in rel_ops
+
+template inline bool operator!=(shared_ptr const & a, shared_ptr const & b)
+{
+ return a.get() != b.get();
+}
+
+#endif
+
+template inline bool operator<(shared_ptr const & a, shared_ptr const & b)
+{
+ return std::less()(a.get(), b.get());
+}
+
+template inline void swap(shared_ptr & a, shared_ptr & b)
+{
+ a.swap(b);
+}
+
+template