Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/poly_collection/detail/segment_backend.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* Copyright 2016-2020 Joaquin M Lopez Munoz.
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * See http://www.boost.org/libs/poly_collection for library home page.
0007  */
0008 
0009 #ifndef BOOST_POLY_COLLECTION_DETAIL_SEGMENT_BACKEND_HPP
0010 #define BOOST_POLY_COLLECTION_DETAIL_SEGMENT_BACKEND_HPP
0011 
0012 #if defined(_MSC_VER)
0013 #pragma once
0014 #endif
0015 
0016 #include <cstddef>
0017 #include <memory>
0018 #include <utility>
0019 
0020 namespace boost{
0021 
0022 namespace poly_collection{
0023 
0024 namespace detail{
0025 
0026 /* Internal *virtual* interface of segment<Model,Allocator> (please note that
0027  * a non-virtual interface exists accessible through downcasting). Member
0028  * functions have been defined to minimize virtual function calls according to
0029  * usage patterns by poly_collection. For instance, ranges are returned rather
0030  * than iterators to allow for caching of and end sentinel at a higher level.
0031  * Passed elements are type erased with [const_]value_pointer.
0032  */
0033 
0034 template<typename Model,typename Allocator>
0035 struct segment_backend
0036 {
0037   using segment_backend_unique_ptr=
0038     std::unique_ptr<segment_backend,void(*)(segment_backend*)>;
0039   using value_pointer=void*;
0040   using const_value_pointer=const void*;
0041   using base_iterator=typename Model::base_iterator;
0042   using const_base_iterator=typename Model::const_base_iterator;
0043   template<typename T>
0044   using const_iterator=typename Model::template const_iterator<T>;
0045   using base_sentinel=typename Model::base_sentinel;
0046   using range=std::pair<base_iterator,base_sentinel>;
0047 
0048   segment_backend()=default;
0049   segment_backend(const segment_backend&)=delete;
0050   segment_backend& operator=(const segment_backend&)=delete;
0051 
0052   virtual                            ~segment_backend()=default;
0053   virtual segment_backend_unique_ptr copy()const=0;
0054   virtual segment_backend_unique_ptr copy(const Allocator&)const=0;
0055   virtual segment_backend_unique_ptr empty_copy(const Allocator&)const=0;
0056   virtual segment_backend_unique_ptr move(const Allocator&)=0;
0057   virtual bool                       equal(const segment_backend&)const=0;
0058 
0059   virtual Allocator     get_allocator()const noexcept=0;
0060   virtual base_iterator begin()const noexcept=0;
0061   virtual base_iterator end()const noexcept=0;
0062   virtual bool          empty()const noexcept=0;
0063   virtual std::size_t   size()const noexcept=0;
0064   virtual std::size_t   max_size()const noexcept=0;
0065   virtual std::size_t   capacity()const noexcept=0;
0066   virtual base_sentinel reserve(std::size_t)=0;
0067   virtual base_sentinel shrink_to_fit()=0;
0068   virtual range         push_back(const_value_pointer)=0;
0069   virtual range         push_back_move(value_pointer)=0;
0070   virtual range         insert(const_base_iterator,const_value_pointer)=0;
0071   virtual range         insert_move(const_base_iterator,value_pointer)=0;
0072   virtual range         erase(const_base_iterator)=0;
0073   virtual range         erase(const_base_iterator,const_base_iterator)=0;
0074   virtual range         erase_till_end(const_base_iterator)=0;
0075   virtual range         erase_from_begin(const_base_iterator)=0;
0076   virtual base_sentinel clear()noexcept=0;
0077 };
0078 
0079 } /* namespace poly_collection::detail */
0080 
0081 } /* namespace poly_collection */
0082 
0083 } /* namespace boost */
0084 
0085 #endif