Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:16

0001 // Boost.Range library
0002 //
0003 //  Copyright Neil Groves 2010. Use, modification and
0004 //  distribution is subject to the Boost Software License, Version
0005 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0006 //  http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // For more information, see http://www.boost.org/libs/range/
0009 //
0010 #ifndef BOOST_RANGE_DETAIL_ANY_ITERATOR_INTERFACE_HPP_INCLUDED
0011 #define BOOST_RANGE_DETAIL_ANY_ITERATOR_INTERFACE_HPP_INCLUDED
0012 
0013 #include <boost/range/detail/any_iterator_buffer.hpp>
0014 #include <boost/iterator/iterator_categories.hpp>
0015 #include <boost/type_traits/is_convertible.hpp>
0016 #include <boost/type_traits/is_reference.hpp>
0017 #include <boost/type_traits/remove_const.hpp>
0018 #include <boost/type_traits/remove_reference.hpp>
0019 
0020 namespace boost
0021 {
0022     namespace range_detail
0023     {
0024         template<class T>
0025         struct const_reference_type_generator
0026         {
0027             typedef typename mpl::if_<
0028                 typename is_reference<T>::type,
0029                 typename add_const<
0030                     typename remove_reference<T>::type
0031                 >::type&,
0032                 T
0033             >::type type;
0034         };
0035 
0036         template<class T>
0037         struct reference_as_value_type_generator
0038         {
0039             typedef typename remove_reference<
0040                 typename remove_const<T>::type
0041             >::type value_type;
0042 
0043             typedef typename mpl::if_<
0044                 typename is_convertible<const value_type&, value_type>::type,
0045                 value_type,
0046                 T
0047             >::type type;
0048         };
0049 
0050         template<
0051             class Reference
0052           , class Buffer
0053         >
0054         struct any_incrementable_iterator_interface
0055         {
0056             typedef Reference reference;
0057             typedef typename const_reference_type_generator<
0058                 Reference
0059             >::type const_reference;
0060             typedef typename reference_as_value_type_generator<
0061                 Reference
0062             >::type reference_as_value_type;
0063 
0064             typedef Buffer buffer_type;
0065 
0066             virtual ~any_incrementable_iterator_interface() {}
0067 
0068             virtual any_incrementable_iterator_interface*
0069                         clone(buffer_type& buffer) const = 0;
0070 
0071             virtual any_incrementable_iterator_interface<const_reference, Buffer>*
0072                         clone_const_ref(buffer_type& buffer) const = 0;
0073 
0074             virtual any_incrementable_iterator_interface<reference_as_value_type, Buffer>*
0075                         clone_reference_as_value(buffer_type& buffer) const = 0;
0076 
0077             virtual void increment() = 0;
0078         };
0079 
0080         template<
0081             class Reference
0082           , class Buffer
0083         >
0084         struct any_single_pass_iterator_interface
0085             : any_incrementable_iterator_interface<Reference, Buffer>
0086         {
0087             typedef typename any_incrementable_iterator_interface<Reference, Buffer>::reference reference;
0088             typedef typename any_incrementable_iterator_interface<Reference, Buffer>::const_reference const_reference;
0089             typedef typename any_incrementable_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
0090             typedef typename any_incrementable_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
0091 
0092             virtual any_single_pass_iterator_interface*
0093                         clone(buffer_type& buffer) const = 0;
0094 
0095             virtual any_single_pass_iterator_interface<const_reference, Buffer>*
0096                         clone_const_ref(buffer_type& buffer) const = 0;
0097 
0098             virtual any_single_pass_iterator_interface<reference_as_value_type, Buffer>*
0099                         clone_reference_as_value(buffer_type& buffer) const = 0;
0100 
0101             virtual reference dereference() const = 0;
0102 
0103             virtual bool equal(const any_single_pass_iterator_interface& other) const = 0;
0104         };
0105 
0106         template<
0107             class Reference
0108           , class Buffer
0109         >
0110         struct any_forward_iterator_interface
0111             : any_single_pass_iterator_interface<Reference, Buffer>
0112         {
0113             typedef typename any_single_pass_iterator_interface<Reference, Buffer>::reference reference;
0114             typedef typename any_single_pass_iterator_interface<Reference, Buffer>::const_reference const_reference;
0115             typedef typename any_single_pass_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
0116             typedef typename any_single_pass_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
0117 
0118             virtual any_forward_iterator_interface*
0119                         clone(buffer_type& buffer) const = 0;
0120 
0121             virtual any_forward_iterator_interface<const_reference, Buffer>*
0122                         clone_const_ref(buffer_type& buffer) const = 0;
0123 
0124             virtual any_forward_iterator_interface<reference_as_value_type, Buffer>*
0125                         clone_reference_as_value(buffer_type& buffer) const = 0;
0126         };
0127 
0128         template<
0129             class Reference
0130           , class Buffer
0131         >
0132         struct any_bidirectional_iterator_interface
0133             : any_forward_iterator_interface<Reference, Buffer>
0134         {
0135             typedef typename any_forward_iterator_interface<Reference, Buffer>::reference reference;
0136             typedef typename any_forward_iterator_interface<Reference, Buffer>::const_reference const_reference;
0137             typedef typename any_forward_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
0138             typedef typename any_forward_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
0139 
0140             virtual any_bidirectional_iterator_interface*
0141                         clone(buffer_type& buffer) const = 0;
0142 
0143             virtual any_bidirectional_iterator_interface<const_reference, Buffer>*
0144                         clone_const_ref(buffer_type& buffer) const = 0;
0145 
0146             virtual any_bidirectional_iterator_interface<reference_as_value_type, Buffer>*
0147                         clone_reference_as_value(buffer_type& buffer) const = 0;
0148 
0149             virtual void decrement() = 0;
0150         };
0151 
0152         template<
0153             class Reference
0154           , class Difference
0155           , class Buffer
0156         >
0157         struct any_random_access_iterator_interface
0158             : any_bidirectional_iterator_interface<
0159                     Reference
0160                   , Buffer
0161                 >
0162         {
0163             typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::reference reference;
0164             typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::const_reference const_reference;
0165             typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
0166             typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
0167             typedef Difference difference_type;
0168 
0169             virtual any_random_access_iterator_interface*
0170                         clone(buffer_type& buffer) const = 0;
0171 
0172             virtual any_random_access_iterator_interface<const_reference, Difference, Buffer>*
0173                         clone_const_ref(buffer_type& buffer) const = 0;
0174 
0175             virtual any_random_access_iterator_interface<reference_as_value_type, Difference, Buffer>*
0176                         clone_reference_as_value(buffer_type& buffer) const = 0;
0177 
0178             virtual void advance(Difference offset) = 0;
0179 
0180             virtual Difference distance_to(const any_random_access_iterator_interface& other) const = 0;
0181         };
0182 
0183         template<
0184             class Traversal
0185           , class Reference
0186           , class Difference
0187           , class Buffer
0188         >
0189         struct any_iterator_interface_type_generator;
0190 
0191         template<
0192             class Reference
0193           , class Difference
0194           , class Buffer
0195         >
0196         struct any_iterator_interface_type_generator<
0197                     incrementable_traversal_tag
0198                   , Reference
0199                   , Difference
0200                   , Buffer
0201                 >
0202         {
0203             typedef any_incrementable_iterator_interface<Reference, Buffer> type;
0204         };
0205 
0206         template<
0207             class Reference
0208           , class Difference
0209           , class Buffer
0210         >
0211         struct any_iterator_interface_type_generator<
0212                     single_pass_traversal_tag
0213                   , Reference
0214                   , Difference
0215                   , Buffer
0216                 >
0217         {
0218             typedef any_single_pass_iterator_interface<Reference, Buffer> type;
0219         };
0220 
0221         template<
0222             class Reference
0223           , class Difference
0224           , class Buffer
0225         >
0226         struct any_iterator_interface_type_generator<
0227                     forward_traversal_tag
0228                   , Reference
0229                   , Difference
0230                   , Buffer
0231                 >
0232         {
0233             typedef any_forward_iterator_interface<Reference, Buffer> type;
0234         };
0235 
0236         template<
0237             class Reference
0238           , class Difference
0239           , class Buffer
0240         >
0241         struct any_iterator_interface_type_generator<
0242                     bidirectional_traversal_tag
0243                   , Reference
0244                   , Difference
0245                   , Buffer
0246                 >
0247         {
0248             typedef any_bidirectional_iterator_interface<Reference, Buffer> type;
0249         };
0250 
0251         template<
0252             class Reference
0253           , class Difference
0254           , class Buffer
0255         >
0256         struct any_iterator_interface_type_generator<
0257                     random_access_traversal_tag
0258                   , Reference
0259                   , Difference
0260                   , Buffer
0261                 >
0262         {
0263             typedef any_random_access_iterator_interface<
0264                         Reference
0265                       , Difference
0266                       , Buffer
0267                     > type;
0268         };
0269 
0270     } // namespace range_detail
0271 } // namespace boost
0272 
0273 #endif // include guard