Header file range/v3/utility/iterator.hpp

#include <meta/meta.hpp>

#include <range/v3/range_fwd.hpp>

#include <range/v3/utility/swap.hpp>

#include <range/v3/utility/move.hpp>

#include <range/v3/utility/iterator_traits.hpp>

#include <range/v3/utility/iterator_concepts.hpp>

#include <range/v3/utility/static_const.hpp>

#include <range/v3/utility/basic_iterator.hpp>

namespace ranges
{
    inline namespace v3
    {
        namespace adl_advance_detail
        {
            using std::advance;
            
            template <typename I>
            constexpr void advance_impl(I& i, iterator_difference_t<I> n, concepts::InputIterator*);
            
            template <typename I>
            constexpr void advance_impl(I& i, iterator_difference_t<I> n, concepts::BidirectionalIterator*);
            
            template <typename I>
            constexpr void advance_impl(I& i, iterator_difference_t<I> n, concepts::RandomAccessIterator*);
            
            template <typename Cur, typename Sent>
            constexpr void advance(basic_iterator<Cur, Sent>& i, iterator_difference_t<basic_iterator<Cur, Sent>> n);
            
            template <typename T>
            constexpr void advance(T*& i, iterator_difference_t<T*> n);
            
            struct advance_fn
            {
                template <typename I, int _concept_requires_106 = 42, typename std::enable_if<(_concept_requires_106==43)||(Iterator<I>()), int>::type=0>
                constexpr void operator()(I& i, iterator_difference_t<I> n) const;
                
                template <typename I, typename S, int _concept_requires_116 = 42, typename std::enable_if<(_concept_requires_116==43)||(Sentinel<S, I>()&&Assignable<I&, S&&>()), int>::type=0>
                constexpr void operator()(I& i, S s) const;
                
                template <typename I, typename S, int _concept_requires_123 = 42, typename std::enable_if<(_concept_requires_123==43)||(Sentinel<S, I>()&&!Assignable<I&, S&&>()), int>::type=0>
                constexpr void operator()(I& i, S s) const;
                
                template <typename I, typename S, int _concept_requires_131 = 42, typename std::enable_if<(_concept_requires_131==43)||(Sentinel<S, I>()), int>::type=0>
                constexpr iterator_difference_t<I> operator()(I& it, iterator_difference_t<I> n, S bound) const;
            };
        }
        
        inline namespace 
        {
            constexpr auto& advance = static_const<adl_advance_detail::advance_fn>::value;
        }
        
        namespace adl_advance_detail{}
        
        struct next_fn
        {
            template <typename I, int _concept_requires_206 = 42, typename std::enable_if<(_concept_requires_206==43)||(Iterator<I>()), int>::type=0>
            constexpr I operator()(I it) const;
            
            template <typename I, int _concept_requires_213 = 42, typename std::enable_if<(_concept_requires_213==43)||(Iterator<I>()), int>::type=0>
            constexpr I operator()(I it, iterator_difference_t<I> n) const;
            
            template <typename I, typename S, int _concept_requires_221 = 42, typename std::enable_if<(_concept_requires_221==43)||(Sentinel<S, I>()), int>::type=0>
            constexpr I operator()(I it, S s) const;
            
            template <typename I, typename S, int _concept_requires_229 = 42, typename std::enable_if<(_concept_requires_229==43)||(Sentinel<S, I>()), int>::type=0>
            constexpr I operator()(I it, iterator_difference_t<I> n, S bound) const;
        };
        
        inline namespace 
        {
            constexpr auto& next = static_const<next_fn>::value;
        }
        
        struct prev_fn
        {
            template <typename I, int _concept_requires_245 = 42, typename std::enable_if<(_concept_requires_245==43)||(BidirectionalIterator<I>()), int>::type=0>
            constexpr I operator()(I it, iterator_difference_t<I> n = 1) const;
        };
        
        inline namespace 
        {
            constexpr auto& prev = static_const<prev_fn>::value;
        }
        
        struct iter_enumerate_fn
        {
            template <typename I, typename S, typename D = iterator_difference_t<I>, int _concept_requires_290 = 42, typename std::enable_if<(_concept_requires_290==43)||(Iterator<I>()&&Sentinel<S, I>()&&Integral<D>()), int>::type=0>
            constexpr std::pair<D, I> operator()(I begin, S end, D d = 0) const;
        };
        
        inline namespace 
        {
            constexpr auto& iter_enumerate = static_const<iter_enumerate_fn>::value;
        }
        
        struct iter_distance_fn
        {
            template <typename I, typename S, typename D = iterator_difference_t<I>, int _concept_requires_322 = 42, typename std::enable_if<(_concept_requires_322==43)||(Iterator<I>()&&Sentinel<S, I>()&&Integral<D>()), int>::type=0>
            constexpr D operator()(I begin, S end, D d = 0) const;
        };
        
        inline namespace 
        {
            constexpr auto& iter_distance = static_const<iter_distance_fn>::value;
        }
        
        struct iter_distance_compare_fn
        {
            template <typename I, typename S, int _concept_requires_369 = 42, typename std::enable_if<(_concept_requires_369==43)||(InputIterator<I>()&&Sentinel<S, I>()), int>::type=0>
            constexpr int operator()(I begin, S end, iterator_difference_t<I> n) const;
        };
        
        inline namespace 
        {
            constexpr auto& iter_distance_compare = static_const<iter_distance_compare_fn>::value;
        }
        
        struct iter_size_fn
        {
            template <typename I, typename S, int _concept_requires_385 = 42, typename std::enable_if<(_concept_requires_385==43)||(SizedSentinel<S, I>()), int>::type=0>
            constexpr iterator_size_t<I> operator()(I begin, S end) const;
        };
        
        inline namespace 
        {
            constexpr auto& iter_size = static_const<iter_size_fn>::value;
        }
        
        struct iter_swap_fn
        {
            template <typename Readable0, typename Readable1, int _concept_requires_402 = 42, typename std::enable_if<(_concept_requires_402==43)||(IndirectlySwappable<Readable0, Readable1>()), int>::type=0>
            constexpr void operator()(Readable0 a, Readable1 b) const noexcept(is_nothrow_indirectly_swappable<Readable0, Readable1>::value);
        };
        
        inline namespace 
        {
            constexpr auto& iter_swap = static_const<iter_swap_fn>::value;
        }
        
        struct iter_move_fn
        {
            template <typename I, int _concept_requires_418 = 42, typename std::enable_if<(_concept_requires_418==43)||(Readable<I>()), int>::type=0>
            constexpr iterator_rvalue_reference_t<I> operator()(I const& i) const noexcept(noexcept(indirect_move(i)));
        };
        
        inline namespace 
        {
            constexpr auto& iter_move = static_const<iter_move_fn>::value;
        }
        
        namespace detail
        {
            template <typename Cont>
            struct back_insert_cursor
            {
                constexpr back_insert_cursor();
            };
        }
        
        template <typename Cont>
        using back_insert_iterator = basic_iterator<detail::back_insert_cursor<Cont>>;
        
        struct back_inserter_fn
        {
            template <typename Cont>
            back_insert_iterator<Cont> operator()(Cont& cont) const;
        };
        
        inline namespace 
        {
            constexpr auto& back_inserter = static_const<back_inserter_fn>::value;
        }
        
        namespace detail
        {
            template <typename Cont>
            struct front_insert_cursor
            {
                constexpr front_insert_cursor();
            };
        }
        
        template <typename Cont>
        using front_insert_iterator = basic_iterator<detail::front_insert_cursor<Cont>>;
        
        struct front_inserter_fn
        {
            template <typename Cont>
            front_insert_iterator<Cont> operator()(Cont& cont) const;
        };
        
        inline namespace 
        {
            constexpr auto& front_inserter = static_const<front_inserter_fn>::value;
        }
        
        namespace detail
        {
            template <typename Cont>
            struct insert_cursor
            {
                constexpr insert_cursor();
            };
        }
        
        template <typename Cont>
        using insert_iterator = basic_iterator<detail::insert_cursor<Cont>>;
        
        struct inserter_fn
        {
            template <typename Cont>
            insert_iterator<Cont> operator()(Cont& cont, typename Cont::iterator where) const;
        };
        
        inline namespace 
        {
            constexpr auto& inserter = static_const<inserter_fn>::value;
        }
        
        template <typename T = void, typename Char = char, typename Traits = std::char_traits<Char>>
        struct ostream_iterator
        {
            using difference_type = std::ptrdiff_t;
            
            using char_type = Char;
            
            using traits_type = Traits;
            
            ostream_iterator() = default;
            
            ostream_iterator(std::basic_ostream<Char, Traits>& sout, Char const* delim = nullptr) noexcept;
            
            proxy operator*() const noexcept;
            
            ostream_iterator& operator++();
            
            ostream_iterator operator++(int);
        };
        
        namespace detail
        {
            template <typename I>
            struct reverse_cursor
            {
                reverse_cursor() = default;
                
                template <typename U, int _concept_requires_719 = 42, typename std::enable_if<(_concept_requires_719==43)||(ConvertibleTo<U, I>()), int>::type=0>
                constexpr reverse_cursor(reverse_cursor<U>const& u);
            };
        }
        
        template <typename I>
        constexpr reverse_iterator<I> make_reverse_iterator(I i);
        
        namespace detail
        {
            template <typename I>
            struct move_cursor
            {
                constexpr move_cursor();
            };
        }
        
        struct make_move_iterator_fn
        {
            template <typename I, int _concept_requires_813 = 42, typename std::enable_if<(_concept_requires_813==43)||(InputIterator<I>()), int>::type=0>
            constexpr move_iterator<I> operator()(I it) const;
        };
        
        inline namespace 
        {
            constexpr auto& make_move_iterator = static_const<make_move_iterator_fn>::value;
        }
        
        template <typename S>
        struct move_sentinel
        {
            constexpr move_sentinel();
            
            explicit constexpr move_sentinel(S s);
            
            template <typename OS, int _concept_requires_835 = 42, typename std::enable_if<(_concept_requires_835==43)||(ConvertibleTo<OS, S>()), int>::type=0>
            explicit constexpr move_sentinel(move_sentinel<OS>const& that);
            
            template <typename OS, int _concept_requires_840 = 42, typename std::enable_if<(_concept_requires_840==43)||(ConvertibleTo<OS, S>()), int>::type=0>
            move_sentinel& operator=(move_sentinel<OS>const& that);
            
            S base() const;
        };
        
        template <typename I, typename S, int _concept_requires_853 = 42, typename std::enable_if<(_concept_requires_853==43)||(Sentinel<S, I>()), int>::type=0>
        bool operator==(move_iterator<I>const& i, move_sentinel<S>const& s);
        
        template <typename I, typename S, int _concept_requires_859 = 42, typename std::enable_if<(_concept_requires_859==43)||(Sentinel<S, I>()), int>::type=0>
        bool operator==(move_sentinel<S>const& s, move_iterator<S>const& i);
        
        template <typename I, typename S, int _concept_requires_865 = 42, typename std::enable_if<(_concept_requires_865==43)||(Sentinel<S, I>()), int>::type=0>
        bool operator!=(move_iterator<S>const& i, move_sentinel<S>const& s);
        
        template <typename I, typename S, int _concept_requires_871 = 42, typename std::enable_if<(_concept_requires_871==43)||(Sentinel<S, I>()), int>::type=0>
        bool operator!=(move_sentinel<S>const& s, move_iterator<S>const& i);
        
        struct make_move_sentinel_fn
        {
            template <typename I, int _concept_requires_880 = 42, typename std::enable_if<(_concept_requires_880==43)||(InputIterator<I>()), int>::type=0>
            constexpr move_iterator<I> operator()(I i) const;
            
            template <typename S, int _concept_requires_887 = 42, typename std::enable_if<(_concept_requires_887==43)||(SemiRegular<S>()&&!InputIterator<S>()), int>::type=0>
            constexpr move_sentinel<S> operator()(S s) const;
        };
        
        inline namespace 
        {
            constexpr auto& make_move_sentinel = static_const<make_move_sentinel_fn>::value;
        }
        
        namespace detail
        {
            template <typename I, bool IsReadable = (bool)Readable<I>()>
            struct move_into_cursor_types{};
            
            template <typename I>
            struct move_into_cursor_types<I, true>
            {
                using value_type = iterator_value_t<I>;
                
                using single_pass = SinglePass<I>;
            };
            
            template <typename I>
            struct move_into_cursor
            : move_into_cursor_types<I>
            {
                constexpr move_into_cursor();
            };
        }
        
        struct move_into_fn
        {
            template <typename I>
            constexpr move_into_iterator<I> operator()(I it) const;
        };
        
        inline namespace 
        {
            constexpr auto& move_into = static_const<move_into_fn>::value;
        }
        
        namespace adl_uncounted_recounted_detail
        {
            template <typename I>
            constexpr I uncounted(I i);
            
            template <typename I>
            constexpr I recounted(I const&, I i, iterator_difference_t<I>);
            
            struct uncounted_fn
            {
                template <typename I>
                constexpr decltype(uncounted((I&&)i)) operator()(I i) const;
            };
            
            struct recounted_fn
            {
                template <typename I, typename J>
                constexpr decltype(recounted((I&&)i, (J&&)j, n)) operator()(I i, J j, iterator_difference_t<J> n) const;
            };
        }
        
        inline namespace 
        {
            constexpr auto& uncounted = static_const<adl_uncounted_recounted_detail::uncounted_fn>::value;
        }
        
        inline namespace 
        {
            constexpr auto& recounted = static_const<adl_uncounted_recounted_detail::recounted_fn>::value;
        }
    }
}

Variable ranges::v3::advance

constexpr auto& advance = static_const<adl_advance_detail::advance_fn>::value;

advance_fn


Variable ranges::v3::next

constexpr auto& next = static_const<next_fn>::value;

next_fn


Variable ranges::v3::prev

constexpr auto& prev = static_const<prev_fn>::value;

prev_fn


Variable ranges::v3::iter_enumerate

constexpr auto& iter_enumerate = static_const<iter_enumerate_fn>::value;

iter_enumerate_fn


Variable ranges::v3::iter_distance

constexpr auto& iter_distance = static_const<iter_distance_fn>::value;

iter_distance_fn


Variable ranges::v3::iter_distance_compare

constexpr auto& iter_distance_compare = static_const<iter_distance_compare_fn>::value;

iter_distance_compare_fn


Variable ranges::v3::iter_size

constexpr auto& iter_size = static_const<iter_size_fn>::value;

iter_size_fn


Variable ranges::v3::iter_swap

constexpr auto& iter_swap = static_const<iter_swap_fn>::value;

iter_swap_fn


Variable ranges::v3::iter_move

constexpr auto& iter_move = static_const<iter_move_fn>::value;

iter_move_fn


Variable ranges::v3::back_inserter

constexpr auto& back_inserter = static_const<back_inserter_fn>::value;

back_inserter_fn


Variable ranges::v3::front_inserter

constexpr auto& front_inserter = static_const<front_inserter_fn>::value;

front_inserter_fn


Variable ranges::v3::inserter

constexpr auto& inserter = static_const<inserter_fn>::value;

inserter_fn


Variable ranges::v3::move_into

constexpr auto& move_into = static_const<move_into_fn>::value;

move_into_fn


Variable ranges::v3::uncounted

constexpr auto& uncounted = static_const<adl_uncounted_recounted_detail::uncounted_fn>::value;

@{