⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sp_counted_impl.hpp

📁 这是VCF框架的代码
💻 HPP
字号:
#ifndef BOOST_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED#define BOOST_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 <thirdparty/common/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 <thirdparty/common/boost/checked_delete.hpp>#include <thirdparty/common/boost/detail/sp_counted_base.hpp>#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)//#include <boost/detail/quick_allocator.hpp>#endif#include <memory>           // std::allocator#include <typeinfo>         // std::type_info in get_deleter#include <cstddef>          // std::size_tnamespace 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 );#endifnamespace 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( std::type_info 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-#endiftemplate<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( std::type_info const & ti )    {        return ti == typeid(D)? &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};#ifdef __CODEGUARD__# pragma option pop#endif} // namespace detail} // namespace boost#endif  // #ifndef BOOST_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -