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

📄 reversible_ptr_container.hpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 HPP
📖 第 1 页 / 共 2 页
字号:
                              BOOST_DEDUCED_TYPENAME#endif                                                            iterator_category<InputIterator>::type() );        }        template< class Compare >        reversible_ptr_container( const Compare& comp,                                  const allocator_type& a )          : c_( comp, a ) {}        template< class ForwardIterator >        reversible_ptr_container( ForwardIterator first,                                  ForwardIterator last,                                  fixed_length_sequence_tag )          : c_( std::distance(first,last) )        {            constructor_impl( first, last,                               std::forward_iterator_tag() );        }        template< class SizeType, class InputIterator >        reversible_ptr_container( SizeType n,                                  InputIterator first,                                  InputIterator last,                                  fixed_length_sequence_tag )          : c_( n )        {            constructor_impl( first, last, #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))#else                              BOOST_DEDUCED_TYPENAME#endif                                                            iterator_category<InputIterator>::type() );        }        template< class Compare >        reversible_ptr_container( const Compare& comp,                                  const allocator_type& a,                                  associative_container_tag )          : c_( comp, a )        { }                        template< class InputIterator >        reversible_ptr_container( InputIterator first,                                  InputIterator last,                                  associative_container_tag )        {            associative_constructor_impl( first, last );        }                template< class InputIterator, class Compare >        reversible_ptr_container( InputIterator first,                                  InputIterator last,                                  const Compare& comp,                                  const allocator_type& a,                                  associative_container_tag )          : c_( comp, a )         {            associative_constructor_impl( first, last );        }        explicit reversible_ptr_container( size_type n )          : c_( n ) {}        template< class Hash, class Pred >        reversible_ptr_container( const Hash& hash,                                  const Pred& pred,                                  const allocator_type& a )          : c_( hash, pred, a ) {}        template< class InputIterator, class Hash, class Pred >        reversible_ptr_container( InputIterator first,                                  InputIterator last,                                  const Hash& hash,                                  const Pred& pred,                                  const allocator_type& a )          : c_( hash, pred, a )        {            associative_constructor_impl( first, last );        }    public:                ~reversible_ptr_container()        {             remove_all();        }            public:                allocator_type get_allocator() const                           {            return c_.get_allocator();         }     public: // container requirements        iterator begin()                        { return iterator( c_.begin() ); }        const_iterator begin() const                  { return const_iterator( c_.begin() ); }        iterator end()                          { return iterator( c_.end() ); }        const_iterator end() const                    { return const_iterator( c_.end() ); }                reverse_iterator rbegin()                       { return reverse_iterator( this->end() ); }         const_reverse_iterator rbegin() const                 { return const_reverse_iterator( this->end() ); }         reverse_iterator rend()                         { return reverse_iterator( this->begin() ); }         const_reverse_iterator rend() const                   { return const_reverse_iterator( this->begin() ); }         const_iterator cbegin() const                  { return const_iterator( c_.begin() ); }        const_iterator cend() const                         { return const_iterator( c_.end() ); }        const_reverse_iterator crbegin() const                  { return const_reverse_iterator( this->end() ); }        const_reverse_iterator crend() const                         { return const_reverse_iterator( this->begin() ); }        void swap( reversible_ptr_container& r ) // nothrow        {             c_.swap( r.c_ );        }                  size_type size() const // nothrow        {            return c_.size();        }        size_type max_size() const // nothrow        {            return c_.max_size();         }                bool empty() const // nothrow        {            return c_.empty();        }    public: // optional container requirements        bool operator==( const reversible_ptr_container& r ) const // nothrow        {             if( size() != r.size() )                return false;            else                return std::equal( begin(), end(), r.begin() );        }        bool operator!=( const reversible_ptr_container& r ) const // nothrow        {            return !(*this == r);        }                bool operator<( const reversible_ptr_container& r ) const // nothrow         {             return std::lexicographical_compare( begin(), end(), r.begin(), r.end() );        }        bool operator<=( const reversible_ptr_container& r ) const // nothrow         {            return !(r < *this);        }        bool operator>( const reversible_ptr_container& r ) const // nothrow         {            return r < *this;        }        bool operator>=( const reversible_ptr_container& r ) const // nothrow         {            return !(*this < r);        }    public: // modifiers        iterator insert( iterator before, Ty_* x )        {            enforce_null_policy( x, "Null pointer in 'insert()'" );            auto_type ptr( x );                            // nothrow            iterator res( c_.insert( before.base(), x ) ); // strong, commit            ptr.release();                                 // nothrow            return res;        }        template< class U >        iterator insert( iterator before, std::auto_ptr<U> x )        {            return insert( before, x.release() );        }        iterator erase( iterator x ) // nothrow        {            BOOST_ASSERT( !empty() );            BOOST_ASSERT( x != end() );            remove( x );            return iterator( c_.erase( x.base() ) );        }        iterator erase( iterator first, iterator last ) // nothrow        {            remove( first, last );            return iterator( c_.erase( first.base(),                                       last.base() ) );        }        template< class Range >        iterator erase( const Range& r )        {            return erase( boost::begin(r), boost::end(r) );        }        void clear()        {            remove_all();            c_.clear();        }            public: // access interface                auto_type release( iterator where )        {             BOOST_ASSERT( where != end() );                        BOOST_PTR_CONTAINER_THROW_EXCEPTION( empty(), bad_ptr_container_operation,                                                 "'release()' on empty container" );                         auto_type ptr( Config::get_pointer( where ) );  // nothrow            c_.erase( where.base() );                       // nothrow            return boost::ptr_container_detail::move( ptr );         }        auto_type replace( iterator where, Ty_* x ) // strong          {             BOOST_ASSERT( where != end() );            enforce_null_policy( x, "Null pointer in 'replace()'" );                        auto_type ptr( x );                        BOOST_PTR_CONTAINER_THROW_EXCEPTION( empty(), bad_ptr_container_operation,                                                 "'replace()' on empty container" );            auto_type old( Config::get_pointer( where ) );  // nothrow                        const_cast<void*&>(*where.base()) = ptr.release();                            return boost::ptr_container_detail::move( old );        }        template< class U >        auto_type replace( iterator where, std::auto_ptr<U> x )        {            return replace( where, x.release() );         }        auto_type replace( size_type idx, Ty_* x ) // strong        {            enforce_null_policy( x, "Null pointer in 'replace()'" );                        auto_type ptr( x );                         BOOST_PTR_CONTAINER_THROW_EXCEPTION( idx >= size(), bad_index,                                                  "'replace()' out of bounds" );                        auto_type old( static_cast<Ty_*>( c_[idx] ) ); // nothrow            c_[idx] = ptr.release();                       // nothrow, commit            return boost::ptr_container_detail::move( old );        }         template< class U >        auto_type replace( size_type idx, std::auto_ptr<U> x )        {            return replace( idx, x.release() );        }                    }; // 'reversible_ptr_container'#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))    #define BOOST_PTR_CONTAINER_DEFINE_RELEASE( base_type ) \    typename base_type::auto_type                   \    release( typename base_type::iterator i )       \    {                                               \        return boost::ptr_container_detail::move(base_type::release(i)); \    }                                               #else#define BOOST_PTR_CONTAINER_DEFINE_RELEASE( base_type ) \    using base_type::release;#endif        //    // two-phase lookup of template functions     // is buggy on most compilers, so we use a macro instead    //#define BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( PC, base_type, this_type ) \    explicit PC( std::auto_ptr<this_type> r )       \    : base_type ( r ) { }                           \                                                    \    PC& operator=( std::auto_ptr<this_type> r )     \    {                                               \        base_type::operator=( r );                  \        return *this;                               \    }                                               \                                                    \    std::auto_ptr<this_type> release()              \    {                                               \      std::auto_ptr<this_type> ptr( new this_type );\      this->swap( *ptr );                           \      return ptr;                                   \    }                                               \    BOOST_PTR_CONTAINER_DEFINE_RELEASE( base_type ) \                                                    \    std::auto_ptr<this_type> clone() const          \    {                                               \       return std::auto_ptr<this_type>( new this_type( this->begin(), this->end() ) ); \    }#define BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( PC, base_type ) \                                                                      \    template< class U >                                               \    PC( const PC<U>& r ) : base_type( r ) { }                         \                                                                      \    PC& operator=( PC r )                                             \    {                                                                 \        this->swap( r );                                              \        return *this;                                                 \    }                                                                 \                                                                           #define BOOST_PTR_CONTAINER_DEFINE_CONSTRUCTORS( PC, base_type )                       \    typedef BOOST_DEDUCED_TYPENAME base_type::iterator        iterator;                \    typedef BOOST_DEDUCED_TYPENAME base_type::size_type       size_type;               \    typedef BOOST_DEDUCED_TYPENAME base_type::const_reference const_reference;         \    typedef BOOST_DEDUCED_TYPENAME base_type::allocator_type  allocator_type;          \    PC() {}                                                                            \    explicit PC( const allocator_type& a ) : base_type(a) {}                           \    template< class InputIterator >                                                    \    PC( InputIterator first, InputIterator last ) : base_type( first, last ) {}        \    template< class InputIterator >                                                    \    PC( InputIterator first, InputIterator last,                                       \        const allocator_type& a ) : base_type( first, last, a ) {}                   #define BOOST_PTR_CONTAINER_DEFINE_NON_INHERITED_MEMBERS( PC, base_type, this_type )           \   BOOST_PTR_CONTAINER_DEFINE_CONSTRUCTORS( PC, base_type )                                    \   BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( PC, base_type, this_type )#define BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( PC, base_type, this_type )  \    BOOST_PTR_CONTAINER_DEFINE_NON_INHERITED_MEMBERS( PC, base_type, this_type )  \    BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( PC, base_type )} // namespace 'ptr_container_detail'    //    // @remark: expose movability of internal move-pointer    //    namespace ptr_container    {                using ptr_container_detail::move;    }} // namespace 'boost'  #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)  #pragma warning(pop)  #endif  #endif

⌨️ 快捷键说明

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