File indexing completed on 2025-01-18 09:38:54
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_ITERATOR_DISTANCE_HPP
0008 #define BOOST_ITERATOR_DISTANCE_HPP
0009
0010 #include <boost/config.hpp>
0011 #include <boost/iterator/iterator_categories.hpp>
0012 #include <boost/iterator/iterator_traits.hpp>
0013
0014 namespace boost {
0015 namespace iterators {
0016
0017 namespace detail {
0018 template <typename SinglePassIterator>
0019 inline BOOST_CXX14_CONSTEXPR typename iterator_difference<SinglePassIterator>::type
0020 distance_impl(
0021 SinglePassIterator first
0022 , SinglePassIterator last
0023 , single_pass_traversal_tag
0024 )
0025 {
0026 typename iterator_difference<SinglePassIterator>::type n = 0;
0027 while (first != last) {
0028 ++first;
0029 ++n;
0030 }
0031 return n;
0032 }
0033
0034 template <typename RandomAccessIterator>
0035 inline BOOST_CXX14_CONSTEXPR typename iterator_difference<RandomAccessIterator>::type
0036 distance_impl(
0037 RandomAccessIterator first
0038 , RandomAccessIterator last
0039 , random_access_traversal_tag
0040 )
0041 {
0042 return last - first;
0043 }
0044 }
0045
0046 namespace distance_adl_barrier {
0047 template <typename SinglePassIterator>
0048 inline BOOST_CXX14_CONSTEXPR typename iterator_difference<SinglePassIterator>::type
0049 distance(SinglePassIterator first, SinglePassIterator last)
0050 {
0051 return detail::distance_impl(
0052 first, last, typename iterator_traversal<SinglePassIterator>::type()
0053 );
0054 }
0055 }
0056
0057 using namespace distance_adl_barrier;
0058
0059 }
0060
0061 using namespace iterators::distance_adl_barrier;
0062
0063 }
0064
0065 #endif