Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //  Copyright Neil Groves 2010. Use, modification and
0002 //  distribution is subject to the Boost Software License, Version
0003 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 //
0006 //
0007 // For more information, see http://www.boost.org/libs/range/
0008 //
0009 #ifndef BOOST_RANGE_ANY_RANGE_HPP_INCLUDED
0010 #define BOOST_RANGE_ANY_RANGE_HPP_INCLUDED
0011 
0012 #include <boost/config.hpp>
0013 #include <boost/iterator/iterator_categories.hpp>
0014 #include <boost/iterator/iterator_traits.hpp>
0015 #include <boost/iterator/iterator_facade.hpp>
0016 #include <boost/iterator/iterator_adaptor.hpp>
0017 #include <boost/range/detail/any_iterator.hpp>
0018 #include <boost/range/concepts.hpp>
0019 #include <boost/range/reference.hpp>
0020 #include <boost/range/value_type.hpp>
0021 #include <boost/range/iterator_range_core.hpp>
0022 
0023 namespace boost
0024 {
0025     namespace range_detail
0026     {
0027         // If T is use_default, return the result of Default, otherwise
0028         // return T.
0029         //
0030         // This is an implementation artifact used to pick intelligent default
0031         // values when the user specified boost::use_default as a template
0032         // parameter.
0033         template<
0034             class T,
0035             class Default
0036         >
0037         struct any_range_default_help
0038             : mpl::eval_if<
0039                 is_same<T, use_default>
0040               , Default
0041               , mpl::identity<T>
0042             >
0043         {
0044         };
0045 
0046         template<
0047             class WrappedRange
0048           , class Value
0049           , class Reference
0050         >
0051         struct any_range_value_type
0052         {
0053 # ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
0054             typedef typename any_range_default_help<
0055                     Value
0056                   , mpl::eval_if<
0057                         is_same<Reference, use_default>
0058                       , range_value<
0059                             typename remove_const<WrappedRange>
0060                         ::type>
0061                       , remove_reference<Reference>
0062                     >
0063                 >::type type;
0064 # else
0065             typedef typename any_range_default_help<
0066                 Value
0067               , range_value<
0068                     typename remove_const<WrappedRange>
0069                 ::type>
0070             >::type type;
0071 # endif
0072         };
0073 
0074         template<
0075             class Value
0076           , class Traversal
0077           , class Reference = Value&
0078           , class Difference = std::ptrdiff_t
0079           , class Buffer = use_default
0080         >
0081         class any_range
0082             : public iterator_range<
0083                         any_iterator<
0084                             Value
0085                           , Traversal
0086                           , Reference
0087                           , Difference
0088                           , typename any_range_default_help<
0089                                 Buffer
0090                               , mpl::identity<any_iterator_default_buffer>
0091                             >::type
0092                         >
0093                     >
0094         {
0095             typedef iterator_range<
0096                         any_iterator<
0097                             Value
0098                           , Traversal
0099                           , Reference
0100                           , Difference
0101                           , typename any_range_default_help<
0102                                 Buffer
0103                               , mpl::identity<any_iterator_default_buffer>
0104                             >::type
0105                         >
0106                     > base_type;
0107 
0108             struct enabler {};
0109             struct disabler {};
0110         public:
0111             any_range()
0112             {
0113             }
0114 
0115             any_range(const any_range& other)
0116                 : base_type(other)
0117             {
0118             }
0119 
0120             template<class WrappedRange>
0121             any_range(WrappedRange& wrapped_range)
0122             : base_type(boost::begin(wrapped_range),
0123                         boost::end(wrapped_range))
0124             {
0125             }
0126 
0127             template<class WrappedRange>
0128             any_range(const WrappedRange& wrapped_range)
0129             : base_type(boost::begin(wrapped_range),
0130                         boost::end(wrapped_range))
0131             {
0132             }
0133 
0134             template<
0135                 class OtherValue
0136               , class OtherTraversal
0137               , class OtherReference
0138               , class OtherDifference
0139             >
0140             any_range(const any_range<
0141                                 OtherValue
0142                               , OtherTraversal
0143                               , OtherReference
0144                               , OtherDifference
0145                               , Buffer
0146                             >& other)
0147             : base_type(boost::begin(other), boost::end(other))
0148             {
0149             }
0150 
0151             template<class Iterator>
0152             any_range(Iterator first, Iterator last)
0153                 : base_type(first, last)
0154             {
0155             }
0156         };
0157 
0158         template<
0159             class WrappedRange
0160           , class Value = use_default
0161           , class Traversal = use_default
0162           , class Reference = use_default
0163           , class Difference = use_default
0164           , class Buffer = use_default
0165         >
0166         struct any_range_type_generator
0167         {
0168             BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<WrappedRange> ));
0169             typedef any_range<
0170                 typename any_range_value_type<
0171                     WrappedRange
0172                   , Value
0173                   , typename any_range_default_help<
0174                         Reference
0175                       , range_reference<WrappedRange>
0176                     >::type
0177                 >::type
0178               , typename any_range_default_help<
0179                             Traversal
0180                           , iterator_traversal<
0181                                 typename range_iterator<WrappedRange>::type
0182                             >
0183                         >::type
0184               , typename any_range_default_help<
0185                     Reference
0186                   , range_reference<WrappedRange>
0187                 >::type
0188               , typename any_range_default_help<
0189                     Difference
0190                   , range_difference<WrappedRange>
0191                 >::type
0192               , typename any_range_default_help<
0193                     Buffer
0194                   , mpl::identity<any_iterator_default_buffer>
0195                 >::type
0196             > type;
0197         };
0198     } // namespace range_detail
0199 
0200     using range_detail::any_range;
0201     using range_detail::any_range_type_generator;
0202 } // namespace boost
0203 
0204 #endif // include guard