Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:47:49

0001 /* Copyright 2016-2017 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_ITERATOR_TRAITS_HPP
0010 #define BOOST_POLY_COLLECTION_DETAIL_ITERATOR_TRAITS_HPP
0011 
0012 #if defined(_MSC_VER)
0013 #pragma once
0014 #endif
0015 
0016 #include <iterator>
0017 #include <type_traits>
0018 
0019 namespace boost{
0020 
0021 namespace poly_collection{
0022 
0023 namespace common_impl{
0024 
0025 template<typename Model,typename Allocator>
0026 class poly_collection;
0027 
0028 }
0029 
0030 namespace detail{
0031 
0032 /* (Internal) bunch of traits-grouped functions for const-preserving
0033  * interoperatibility between iterators and local iterators of a
0034  * poly_collection.
0035  */
0036 
0037 template<typename Iterator>
0038 struct poly_collection_of /* to be specialized for iterator impls */
0039 {
0040  using type=void;
0041 };
0042 
0043 template<typename PolyCollection>
0044 struct model_of;
0045 
0046 template<typename Model,typename Allocator>
0047 struct model_of<common_impl::poly_collection<Model,Allocator>>
0048 {
0049   using type=Model;
0050 };
0051 
0052 template<typename Iterator>
0053 struct iterator_traits
0054 {
0055   using container_type=typename poly_collection_of<Iterator>::type;
0056   using is_const_iterator=typename std::is_const<
0057     typename std::remove_reference<
0058       typename std::iterator_traits<Iterator>::reference
0059     >::type
0060   >::type;
0061   using iterator=typename std::conditional<
0062     is_const_iterator::value,
0063     typename container_type::const_iterator,   
0064     typename container_type::iterator
0065   >::type;
0066   using base_segment_info_iterator=typename std::conditional<
0067     is_const_iterator::value,
0068     typename container_type::const_base_segment_info_iterator,   
0069     typename container_type::base_segment_info_iterator
0070   >::type;
0071   using local_base_iterator=typename std::conditional<
0072     is_const_iterator::value,
0073     typename container_type::const_local_base_iterator,   
0074     typename container_type::local_base_iterator
0075   >::type;
0076   template<typename T>
0077   using local_iterator=typename std::conditional<
0078     is_const_iterator::value,
0079     typename container_type::template const_local_iterator<T>,   
0080     typename container_type::template local_iterator<T>
0081   >::type;
0082 
0083   static base_segment_info_iterator
0084   base_segment_info_iterator_from(iterator it)noexcept{return it.mapit;} 
0085 
0086   static base_segment_info_iterator
0087   base_segment_info_iterator_from(local_base_iterator it)noexcept
0088     {return it.mapit;}
0089 
0090   static base_segment_info_iterator
0091   end_base_segment_info_iterator_from(iterator it)noexcept{return it.mapend;} 
0092 
0093   static local_base_iterator
0094   local_base_iterator_from(iterator it)noexcept
0095   {
0096     return {
0097       it.mapit,
0098       model_of<container_type>::type::nonconst_iterator(it.segpos)
0099     };
0100   }
0101 
0102   static iterator 
0103   iterator_from(
0104     local_base_iterator lbit,base_segment_info_iterator mapend)noexcept
0105   {
0106     return {lbit.mapit,mapend.base(),lbit.base()};
0107   }
0108 };
0109 
0110 } /* namespace poly_collection::detail */
0111 
0112 } /* namespace poly_collection */
0113 
0114 } /* namespace boost */
0115 
0116 #endif