]> git.lyx.org Git - features.git/blobdiff - boost/boost/smart_ptr/detail/sp_counted_impl.hpp
boost: add eol property
[features.git] / boost / boost / smart_ptr / detail / sp_counted_impl.hpp
index c513b82aa644dc3f6edcf2444d26449adcd5dba6..397421ae9fae05e5efa6d081333a86ed5f6e1dcf 100644 (file)
-#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED\r
-#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED\r
-\r
-// MS compatible compilers support #pragma once\r
-\r
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)\r
-# pragma once\r
-#endif\r
-\r
-//\r
-//  detail/sp_counted_impl.hpp\r
-//\r
-//  Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.\r
-//  Copyright 2004-2005 Peter Dimov\r
-//\r
-// Distributed under the Boost Software License, Version 1.0. (See\r
-// accompanying file LICENSE_1_0.txt or copy at\r
-// http://www.boost.org/LICENSE_1_0.txt)\r
-//\r
-\r
-#include <boost/config.hpp>\r
-\r
-#if defined(BOOST_SP_USE_STD_ALLOCATOR) && defined(BOOST_SP_USE_QUICK_ALLOCATOR)\r
-# error BOOST_SP_USE_STD_ALLOCATOR and BOOST_SP_USE_QUICK_ALLOCATOR are incompatible.\r
-#endif\r
-\r
-#include <boost/checked_delete.hpp>\r
-#include <boost/smart_ptr/detail/sp_counted_base.hpp>\r
-\r
-#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)\r
-#include <boost/smart_ptr/detail/quick_allocator.hpp>\r
-#endif\r
-\r
-#if defined(BOOST_SP_USE_STD_ALLOCATOR)\r
-#include <memory>           // std::allocator\r
-#endif\r
-\r
-#include <cstddef>          // std::size_t\r
-\r
-namespace boost\r
-{\r
-\r
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)\r
-\r
-void sp_scalar_constructor_hook( void * px, std::size_t size, void * pn );\r
-void sp_scalar_destructor_hook( void * px, std::size_t size, void * pn );\r
-\r
-#endif\r
-\r
-namespace detail\r
-{\r
-\r
-template<class X> class sp_counted_impl_p: public sp_counted_base\r
-{\r
-private:\r
-\r
-    X * px_;\r
-\r
-    sp_counted_impl_p( sp_counted_impl_p const & );\r
-    sp_counted_impl_p & operator= ( sp_counted_impl_p const & );\r
-\r
-    typedef sp_counted_impl_p<X> this_type;\r
-\r
-public:\r
-\r
-    explicit sp_counted_impl_p( X * px ): px_( px )\r
-    {\r
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)\r
-        boost::sp_scalar_constructor_hook( px, sizeof(X), this );\r
-#endif\r
-    }\r
-\r
-    virtual void dispose() // nothrow\r
-    {\r
-#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)\r
-        boost::sp_scalar_destructor_hook( px_, sizeof(X), this );\r
-#endif\r
-        boost::checked_delete( px_ );\r
-    }\r
-\r
-    virtual void * get_deleter( detail::sp_typeinfo const & )\r
-    {\r
-        return 0;\r
-    }\r
-\r
-#if defined(BOOST_SP_USE_STD_ALLOCATOR)\r
-\r
-    void * operator new( std::size_t )\r
-    {\r
-        return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) );\r
-    }\r
-\r
-    void operator delete( void * p )\r
-    {\r
-        std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 );\r
-    }\r
-\r
-#endif\r
-\r
-#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)\r
-\r
-    void * operator new( std::size_t )\r
-    {\r
-        return quick_allocator<this_type>::alloc();\r
-    }\r
-\r
-    void operator delete( void * p )\r
-    {\r
-        quick_allocator<this_type>::dealloc( p );\r
-    }\r
-\r
-#endif\r
-};\r
-\r
-//\r
-// Borland's Codeguard trips up over the -Vx- option here:\r
-//\r
-#ifdef __CODEGUARD__\r
-# pragma option push -Vx-\r
-#endif\r
-\r
-template<class P, class D> class sp_counted_impl_pd: public sp_counted_base\r
-{\r
-private:\r
-\r
-    P ptr; // copy constructor must not throw\r
-    D del; // copy constructor must not throw\r
-\r
-    sp_counted_impl_pd( sp_counted_impl_pd const & );\r
-    sp_counted_impl_pd & operator= ( sp_counted_impl_pd const & );\r
-\r
-    typedef sp_counted_impl_pd<P, D> this_type;\r
-\r
-public:\r
-\r
-    // pre: d(p) must not throw\r
-\r
-    sp_counted_impl_pd( P p, D d ): ptr(p), del(d)\r
-    {\r
-    }\r
-\r
-    virtual void dispose() // nothrow\r
-    {\r
-        del( ptr );\r
-    }\r
-\r
-    virtual void * get_deleter( detail::sp_typeinfo const & ti )\r
-    {\r
-        return ti == BOOST_SP_TYPEID(D)? &reinterpret_cast<char&>( del ): 0;\r
-    }\r
-\r
-#if defined(BOOST_SP_USE_STD_ALLOCATOR)\r
-\r
-    void * operator new( std::size_t )\r
-    {\r
-        return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) );\r
-    }\r
-\r
-    void operator delete( void * p )\r
-    {\r
-        std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 );\r
-    }\r
-\r
-#endif\r
-\r
-#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)\r
-\r
-    void * operator new( std::size_t )\r
-    {\r
-        return quick_allocator<this_type>::alloc();\r
-    }\r
-\r
-    void operator delete( void * p )\r
-    {\r
-        quick_allocator<this_type>::dealloc( p );\r
-    }\r
-\r
-#endif\r
-};\r
-\r
-template<class P, class D, class A> class sp_counted_impl_pda: public sp_counted_base\r
-{\r
-private:\r
-\r
-    P p_; // copy constructor must not throw\r
-    D d_; // copy constructor must not throw\r
-    A a_; // copy constructor must not throw\r
-\r
-    sp_counted_impl_pda( sp_counted_impl_pda const & );\r
-    sp_counted_impl_pda & operator= ( sp_counted_impl_pda const & );\r
-\r
-    typedef sp_counted_impl_pda<P, D, A> this_type;\r
-\r
-public:\r
-\r
-    // pre: d( p ) must not throw\r
-\r
-    sp_counted_impl_pda( P p, D d, A a ): p_( p ), d_( d ), a_( a )\r
-    {\r
-    }\r
-\r
-    virtual void dispose() // nothrow\r
-    {\r
-        d_( p_ );\r
-    }\r
-\r
-    virtual void destroy() // nothrow\r
-    {\r
-        typedef typename A::template rebind< this_type >::other A2;\r
-\r
-        A2 a2( a_ );\r
-\r
-        this->~this_type();\r
-        a2.deallocate( this, 1 );\r
-    }\r
-\r
-    virtual void * get_deleter( detail::sp_typeinfo const & ti )\r
-    {\r
-        return ti == BOOST_SP_TYPEID( D )? &reinterpret_cast<char&>( d_ ): 0;\r
-    }\r
-};\r
-\r
-#ifdef __CODEGUARD__\r
-# pragma option pop\r
-#endif\r
-\r
-} // namespace detail\r
-\r
-} // namespace boost\r
-\r
-#endif  // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED\r
+#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
+#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED
+
+// MS compatible compilers support #pragma once
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+//
+//  detail/sp_counted_impl.hpp
+//
+//  Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
+//  Copyright 2004-2005 Peter Dimov
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/config.hpp>
+
+#if defined(BOOST_SP_USE_STD_ALLOCATOR) && defined(BOOST_SP_USE_QUICK_ALLOCATOR)
+# error BOOST_SP_USE_STD_ALLOCATOR and BOOST_SP_USE_QUICK_ALLOCATOR are incompatible.
+#endif
+
+#include <boost/checked_delete.hpp>
+#include <boost/smart_ptr/detail/sp_counted_base.hpp>
+
+#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
+#include <boost/smart_ptr/detail/quick_allocator.hpp>
+#endif
+
+#if defined(BOOST_SP_USE_STD_ALLOCATOR)
+#include <memory>           // std::allocator
+#endif
+
+#include <cstddef>          // std::size_t
+
+namespace boost
+{
+
+#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
+
+void sp_scalar_constructor_hook( void * px, std::size_t size, void * pn );
+void sp_scalar_destructor_hook( void * px, std::size_t size, void * pn );
+
+#endif
+
+namespace detail
+{
+
+template<class X> class sp_counted_impl_p: public sp_counted_base
+{
+private:
+
+    X * px_;
+
+    sp_counted_impl_p( sp_counted_impl_p const & );
+    sp_counted_impl_p & operator= ( sp_counted_impl_p const & );
+
+    typedef sp_counted_impl_p<X> this_type;
+
+public:
+
+    explicit sp_counted_impl_p( X * px ): px_( px )
+    {
+#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
+        boost::sp_scalar_constructor_hook( px, sizeof(X), this );
+#endif
+    }
+
+    virtual void dispose() // nothrow
+    {
+#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
+        boost::sp_scalar_destructor_hook( px_, sizeof(X), this );
+#endif
+        boost::checked_delete( px_ );
+    }
+
+    virtual void * get_deleter( detail::sp_typeinfo const & )
+    {
+        return 0;
+    }
+
+#if defined(BOOST_SP_USE_STD_ALLOCATOR)
+
+    void * operator new( std::size_t )
+    {
+        return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) );
+    }
+
+    void operator delete( void * p )
+    {
+        std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 );
+    }
+
+#endif
+
+#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
+
+    void * operator new( std::size_t )
+    {
+        return quick_allocator<this_type>::alloc();
+    }
+
+    void operator delete( void * p )
+    {
+        quick_allocator<this_type>::dealloc( p );
+    }
+
+#endif
+};
+
+//
+// Borland's Codeguard trips up over the -Vx- option here:
+//
+#ifdef __CODEGUARD__
+# pragma option push -Vx-
+#endif
+
+template<class P, class D> class sp_counted_impl_pd: public sp_counted_base
+{
+private:
+
+    P ptr; // copy constructor must not throw
+    D del; // copy constructor must not throw
+
+    sp_counted_impl_pd( sp_counted_impl_pd const & );
+    sp_counted_impl_pd & operator= ( sp_counted_impl_pd const & );
+
+    typedef sp_counted_impl_pd<P, D> this_type;
+
+public:
+
+    // pre: d(p) must not throw
+
+    sp_counted_impl_pd( P p, D d ): ptr(p), del(d)
+    {
+    }
+
+    virtual void dispose() // nothrow
+    {
+        del( ptr );
+    }
+
+    virtual void * get_deleter( detail::sp_typeinfo const & ti )
+    {
+        return ti == BOOST_SP_TYPEID(D)? &reinterpret_cast<char&>( del ): 0;
+    }
+
+#if defined(BOOST_SP_USE_STD_ALLOCATOR)
+
+    void * operator new( std::size_t )
+    {
+        return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) );
+    }
+
+    void operator delete( void * p )
+    {
+        std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 );
+    }
+
+#endif
+
+#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
+
+    void * operator new( std::size_t )
+    {
+        return quick_allocator<this_type>::alloc();
+    }
+
+    void operator delete( void * p )
+    {
+        quick_allocator<this_type>::dealloc( p );
+    }
+
+#endif
+};
+
+template<class P, class D, class A> class sp_counted_impl_pda: public sp_counted_base
+{
+private:
+
+    P p_; // copy constructor must not throw
+    D d_; // copy constructor must not throw
+    A a_; // copy constructor must not throw
+
+    sp_counted_impl_pda( sp_counted_impl_pda const & );
+    sp_counted_impl_pda & operator= ( sp_counted_impl_pda const & );
+
+    typedef sp_counted_impl_pda<P, D, A> this_type;
+
+public:
+
+    // pre: d( p ) must not throw
+
+    sp_counted_impl_pda( P p, D d, A a ): p_( p ), d_( d ), a_( a )
+    {
+    }
+
+    virtual void dispose() // nothrow
+    {
+        d_( p_ );
+    }
+
+    virtual void destroy() // nothrow
+    {
+        typedef typename A::template rebind< this_type >::other A2;
+
+        A2 a2( a_ );
+
+        this->~this_type();
+        a2.deallocate( this, 1 );
+    }
+
+    virtual void * get_deleter( detail::sp_typeinfo const & ti )
+    {
+        return ti == BOOST_SP_TYPEID( D )? &reinterpret_cast<char&>( d_ ): 0;
+    }
+};
+
+#ifdef __CODEGUARD__
+# pragma option pop
+#endif
+
+} // namespace detail
+
+} // namespace boost
+
+#endif  // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED