Header file range/v3/view_adaptor.hpp

#include <meta/meta.hpp>

#include <range/v3/range_fwd.hpp>

#include <range/v3/size.hpp>

#include <range/v3/distance.hpp>

#include <range/v3/view_facade.hpp>

#include <range/v3/range_traits.hpp>

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

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

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

#include <range/v3/view/all.hpp>

namespace ranges
{
    inline namespace v3
    {
        namespace detail
        {
            template <typename Derived>
            using begin_adaptor_t = decltype(range_access::begin_adaptor(std::declval<Derived&>(), 42));
            
            template <typename Derived>
            using end_adaptor_t = decltype(range_access::end_adaptor(std::declval<Derived&>(), 42));
            
            template <typename Derived>
            using adapted_iterator_t = decltype(std::declval<begin_adaptor_t<Derived>>().begin(std::declval<Derived&>()));
            
            template <typename Derived>
            using adapted_sentinel_t = decltype(std::declval<end_adaptor_t<Derived>>().end(std::declval<Derived&>()));
            
            struct adaptor_base_current_mem_fn{};
            
            template <typename BaseIter, typename Adapt, typename Enable = void>
            struct adaptor_value_type_2_
            : compressed_pair<BaseIter, Adapt>
            {
                using compressed_pair<BaseIter, Adapt>::compressed_pair;
            };
            
            template <typename BaseIter, typename Adapt>
            struct adaptor_value_type_2_<BaseIter, Adapt, meta::void_<decltype(Adapt::get(BaseIter{}, adaptor_base_current_mem_fn{}))>>
            : compressed_pair<BaseIter, Adapt>
            {
                using compressed_pair<BaseIter, Adapt>::compressed_pair;
                
                using value_type = iterator_value_t<BaseIter>;
            };
            
            template <typename BaseIter, typename Adapt, typename Enable = void>
            struct adaptor_value_type_
            : adaptor_value_type_2_<BaseIter, Adapt>
            {
                using adaptor_value_type_2_<BaseIter, Adapt>::adaptor_value_type_2_;
            };
            
            template <typename BaseIter, typename Adapt>
            struct adaptor_value_type_<BaseIter, Adapt, meta::void_<typename Adapt::value_type>>
            : compressed_pair<BaseIter, Adapt>
            {
                using compressed_pair<BaseIter, Adapt>::compressed_pair;
                
                using value_type = typename Adapt::value_type;
            };
        }
        
        template <typename Derived>
        using base_range_t = meta::_t<range_access::base_range<Derived>>;
        
        struct adaptor_base
        {
            adaptor_base() = default;
            
            adaptor_base(adaptor_base&&) = default;
            
            adaptor_base(adaptor_base const&) = default;
            
            adaptor_base& operator=(adaptor_base&&) = default;
            
            adaptor_base& operator=(adaptor_base const&) = default;
            
            adaptor_base(detail::any, detail::any = {}, detail::any = {});
            
            template <typename Rng>
            range_iterator_t<base_range_t<Rng>> begin(Rng& rng) const;
            
            template <typename Rng>
            range_sentinel_t<base_range_t<Rng>> end(Rng& rng) const;
            
            template <typename I, int _concept_requires_119 = 42, typename std::enable_if<(_concept_requires_119==43)||(EqualityComparable<I>()), int>::type=0>
            static bool equal(I const& it0, I const& it1);
            
            template <typename I, int _concept_requires_124 = 42, typename std::enable_if<(_concept_requires_124==43)||(Iterator<I>()), int>::type=0>
            static iterator_reference_t<I> get(I const& it, detail::adaptor_base_current_mem_fn = {}) noexcept(noexcept(iterator_reference_t<I>(*it)));
            
            template <typename I, int _concept_requires_131 = 42, typename std::enable_if<(_concept_requires_131==43)||(Iterator<I>()), int>::type=0>
            static void next(I& it);
            
            template <typename I, int _concept_requires_136 = 42, typename std::enable_if<(_concept_requires_136==43)||(BidirectionalIterator<I>()), int>::type=0>
            static void prev(I& it);
            
            template <typename I, int _concept_requires_141 = 42, typename std::enable_if<(_concept_requires_141==43)||(RandomAccessIterator<I>()), int>::type=0>
            static void advance(I& it, iterator_difference_t<I> n);
            
            template <typename I, int _concept_requires_146 = 42, typename std::enable_if<(_concept_requires_146==43)||(SizedSentinel<I, I>()), int>::type=0>
            static iterator_difference_t<I> distance_to(I const& it0, I const& it1);
            
            template <typename I, typename S, int _concept_requires_151 = 42, typename std::enable_if<(_concept_requires_151==43)||(Sentinel<S, I>()), int>::type=0>
            static constexpr bool empty(I const& it, S const& end);
        };
        
        template <typename BaseIter, typename Adapt>
        struct adaptor_cursor
        {
            using base_t::base_t;
        };
        
        template <typename BaseSent, typename Adapt>
        struct adaptor_sentinel
        {
            using compressed_pair<BaseSent, Adapt>::compressed_pair;
        };
        
        template <typename D>
        using adaptor_cursor_t = adaptor_cursor<detail::adapted_iterator_t<D>, detail::begin_adaptor_t<D>>;
        
        template <typename D>
        using adaptor_sentinel_t = meta::if_<meta::and_<Same<detail::adapted_iterator_t<D>, detail::adapted_sentinel_t<D>>, Same<detail::begin_adaptor_t<D>, detail::end_adaptor_t<D>>>, adaptor_cursor<detail::adapted_iterator_t<D>, detail::begin_adaptor_t<D>>, adaptor_sentinel<detail::adapted_sentinel_t<D>, detail::end_adaptor_t<D>>>;
        
        template <typename Derived, typename BaseRng, cardinality Cardinality>
        struct view_adaptor
        : view_facade<Derived, Cardinality>
        {
        protected:
            ~view_adaptor() = default;
            
        public:
            view_adaptor() = default;
            
            view_adaptor(view_adaptor&&) = default;
            
            view_adaptor(view_adaptor const&) = default;
            
            view_adaptor& operator=(view_adaptor&&) = default;
            
            view_adaptor& operator=(view_adaptor const&) = default;
            
            constexpr view_adaptor(BaseRng&& rng);
            
            base_range_t& base();
            
            base_range_t const& base() const;
        };
    }
}

Alias template ranges::v3::base_range_t<Derived>

template <typename Derived>
using base_range_t = meta::_t<range_access::base_range<Derived>>;

@{