Header file range/v3/view_interface.hpp

#include <meta/meta.hpp>

#include <range/v3/range_fwd.hpp>

#include <range/v3/range_concepts.hpp>

#include <range/v3/range_traits.hpp>

#include <range/v3/begin_end.hpp>

#include <range/v3/to_container.hpp>

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

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

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

namespace ranges
{
    inline namespace v3
    {
        namespace detail
        {
            template <typename From, typename To = From>
            struct slice_bounds
            {
                From from;
                
                To to;
                
                template <typename F, typename T, int _concept_requires_40 = 42, typename std::enable_if<(_concept_requires_40==43)||(ConvertibleTo<F, From>()&&ConvertibleTo<T, To>()), int>::type=0>
                slice_bounds(F from, T to);
            };
            
            template <typename Int>
            struct from_end_
            {
                Int dist_;
                
                template <typename Other, int _concept_requires_52 = 42, typename std::enable_if<(_concept_requires_52==43)||(Integral<Other>()&&ExplicitlyConvertibleTo<Other, Int>()), int>::type=0>
                operator from_end_<Other>() const;
            };
        }
        
        template <typename Derived, cardinality Cardinality>
        struct view_interface;
    }
}

Class template ranges::v3::view_interface<Derived, Cardinality>

template <typename Derived, cardinality Cardinality>
struct view_interface
: basic_view<Cardinality>
{
protected:
    Derived& derived();
    
    Derived const& derived() const;
    
    ~view_interface() = default;
    
public:
    view_interface() = default;
    
    view_interface(view_interface&&) = default;
    
    view_interface(view_interface const&) = default;
    
    view_interface& operator=(view_interface&&) = default;
    
    view_interface& operator=(view_interface const&) = default;
    
    constexpr bool empty() const;
    
    constexpr bool operator!() const;
    
    explicit constexpr operator bool() const;
    
    template <typename D = Derived, int _concept_requires_99 = 42, typename std::enable_if<(_concept_requires_99==43)||(Same<D, Derived>()&&Cardinality>=0), int>::type=0>
    constexpr range_size_t<D> size() const;
    
    template <typename D = Derived, int _concept_requires_105 = 42, typename std::enable_if<(_concept_requires_105==43)||(Same<D, Derived>()&&Cardinality<0&&SizedSentinel<range_sentinel_t<const D>, range_iterator_t<const D>>()), int>::type=0>
    constexpr range_size_t<D> size() const;
    
    template <typename D = Derived, int _concept_requires_113 = 42, typename std::enable_if<(_concept_requires_113==43)||(Same<D, Derived>()), int>::type=0>
    range_reference_t<D> front();
    
    template <typename D = Derived, int _concept_requires_120 = 42, typename std::enable_if<(_concept_requires_120==43)||(Same<D, Derived>()), int>::type=0>
    range_reference_t<D const> front() const;
    
    template <typename D = Derived, int _concept_requires_127 = 42, typename std::enable_if<(_concept_requires_127==43)||(Same<D, Derived>()&&BoundedView<D>()&&BidirectionalView<D>()), int>::type=0>
    range_reference_t<D> back();
    
    template <typename D = Derived, int _concept_requires_134 = 42, typename std::enable_if<(_concept_requires_134==43)||(Same<D, Derived>()&&BoundedView<D const>()&&BidirectionalView<D const>()), int>::type=0>
    range_reference_t<D const> back() const;
    
    template <typename D = Derived, int _concept_requires_141 = 42, typename std::enable_if<(_concept_requires_141==43)||(Same<D, Derived>()&&RandomAccessView<D>()), int>::type=0>
    decltype(std::declval<D&>().begin()[n]) operator[](range_difference_t<D> n);
    
    template <typename D = Derived, int _concept_requires_149 = 42, typename std::enable_if<(_concept_requires_149==43)||(Same<D, Derived>()&&RandomAccessView<D const>()), int>::type=0>
    decltype(std::declval<D const&>().begin()[n]) operator[](range_difference_t<D> n) const;
    
    template <typename D = Derived, typename Slice = view::slice_fn, int _concept_requires_158 = 42, typename std::enable_if<(_concept_requires_158==43)||(Same<D, Derived>()), int>::type=0>
    decltype(std::declval<Slice>()(std::declval<D&>(), offs.from, offs.to)) operator[](detail::slice_bounds<range_difference_t<D>> offs);
    
    template <typename D = Derived, typename Slice = view::slice_fn, int _concept_requires_166 = 42, typename std::enable_if<(_concept_requires_166==43)||(Same<D, Derived>()), int>::type=0>
    decltype(std::declval<Slice>()(std::declval<D const&>(), offs.from, offs.to)) operator[](detail::slice_bounds<range_difference_t<D>> offs) const;
    
    template <typename D = Derived, typename Slice = view::slice_fn, int _concept_requires_175 = 42, typename std::enable_if<(_concept_requires_175==43)||(Same<D, Derived>()), int>::type=0>
    decltype(std::declval<Slice>()(std::declval<D&>(), offs.from, offs.to)) operator[](detail::slice_bounds<range_difference_t<D>, detail::from_end_<range_difference_t<D>>> offs);
    
    template <typename D = Derived, typename Slice = view::slice_fn, int _concept_requires_184 = 42, typename std::enable_if<(_concept_requires_184==43)||(Same<D, Derived>()), int>::type=0>
    decltype(std::declval<Slice>()(std::declval<D const&>(), offs.from, offs.to)) operator[](detail::slice_bounds<range_difference_t<D>, detail::from_end_<range_difference_t<D>>> offs) const;
    
    template <typename D = Derived, typename Slice = view::slice_fn, int _concept_requires_194 = 42, typename std::enable_if<(_concept_requires_194==43)||(Same<D, Derived>()), int>::type=0>
    decltype(std::declval<Slice>()(std::declval<D&>(), offs.from, offs.to)) operator[](detail::slice_bounds<detail::from_end_<range_difference_t<D>>, detail::from_end_<range_difference_t<D>>> offs);
    
    template <typename D = Derived, typename Slice = view::slice_fn, int _concept_requires_203 = 42, typename std::enable_if<(_concept_requires_203==43)||(Same<D, Derived>()), int>::type=0>
    decltype(std::declval<Slice>()(std::declval<D const&>(), offs.from, offs.to)) operator[](detail::slice_bounds<detail::from_end_<range_difference_t<D>>, detail::from_end_<range_difference_t<D>>> offs) const;
    
    template <typename D = Derived, typename Slice = view::slice_fn, int _concept_requires_213 = 42, typename std::enable_if<(_concept_requires_213==43)||(Same<D, Derived>()), int>::type=0>
    decltype(std::declval<Slice>()(std::declval<D&>(), offs.from, offs.to)) operator[](detail::slice_bounds<range_difference_t<D>, end_fn> offs);
    
    template <typename D = Derived, typename Slice = view::slice_fn, int _concept_requires_221 = 42, typename std::enable_if<(_concept_requires_221==43)||(Same<D, Derived>()), int>::type=0>
    decltype(std::declval<Slice>()(std::declval<D const&>(), offs.from, offs.to)) operator[](detail::slice_bounds<range_difference_t<D>, end_fn> offs) const;
    
    template <typename D = Derived, typename Slice = view::slice_fn, int _concept_requires_230 = 42, typename std::enable_if<(_concept_requires_230==43)||(Same<D, Derived>()), int>::type=0>
    decltype(std::declval<Slice>()(std::declval<D&>(), offs.from, offs.to)) operator[](detail::slice_bounds<detail::from_end_<range_difference_t<D>>, end_fn> offs);
    
    template <typename D = Derived, typename Slice = view::slice_fn, int _concept_requires_238 = 42, typename std::enable_if<(_concept_requires_238==43)||(Same<D, Derived>()), int>::type=0>
    decltype(std::declval<Slice>()(std::declval<D const&>(), offs.from, offs.to)) operator[](detail::slice_bounds<detail::from_end_<range_difference_t<D>>, end_fn> offs) const;
    
    template <typename Container, typename D = Derived, typename Alloc = typename Container::allocator_type, int _concept_requires_247 = 42, typename std::enable_if<(_concept_requires_247==43)||(detail::ConvertibleToContainer<D, Container>()), int>::type=0>
    operator Container();
    
    template <typename Container, typename D = Derived, typename Alloc = typename Container::allocator_type, int _concept_requires_255 = 42, typename std::enable_if<(_concept_requires_255==43)||(detail::ConvertibleToContainer<D const, Container>()), int>::type=0>
    operator Container() const;
};

@{

Function template ranges::v3::view_interface<Derived, Cardinality>::size<D, _concept_requires_99>

template <typename D = Derived, int _concept_requires_99 = 42, typename std::enable_if<(_concept_requires_99==43)||(Same<D, Derived>()&&Cardinality>=0), int>::type=0>
constexpr range_size_t<D> size() const;

Access the size of the range, if it can be determined:


Function template ranges::v3::view_interface<Derived, Cardinality>::front<D, _concept_requires_113>

template <typename D = Derived, int _concept_requires_113 = 42, typename std::enable_if<(_concept_requires_113==43)||(Same<D, Derived>()), int>::type=0>
range_reference_t<D> front();

Access the first element in a range:


Function template ranges::v3::view_interface<Derived, Cardinality>::back<D, _concept_requires_127>

template <typename D = Derived, int _concept_requires_127 = 42, typename std::enable_if<(_concept_requires_127==43)||(Same<D, Derived>()&&BoundedView<D>()&&BidirectionalView<D>()), int>::type=0>
range_reference_t<D> back();

Access the last element in a range:


Function template ranges::v3::view_interface<Derived, Cardinality>::operator[]<D, _concept_requires_141>

template <typename D = Derived, int _concept_requires_141 = 42, typename std::enable_if<(_concept_requires_141==43)||(Same<D, Derived>()&&RandomAccessView<D>()), int>::type=0>
decltype(std::declval<D&>().begin()[n]) operator[](range_difference_t<D> n);

Simple indexing:


Function template ranges::v3::view_interface<Derived, Cardinality>::operator[]<D, Slice, _concept_requires_158>

template <typename D = Derived, typename Slice = view::slice_fn, int _concept_requires_158 = 42, typename std::enable_if<(_concept_requires_158==43)||(Same<D, Derived>()), int>::type=0>
decltype(std::declval<Slice>()(std::declval<D&>(), offs.from, offs.to)) operator[](detail::slice_bounds<range_difference_t<D>> offs);

Python-ic slicing:


Function template ranges::v3::view_interface<Derived, Cardinality>::operator Container<Container, D, Alloc, _concept_requires_247>

template <typename Container, typename D = Derived, typename Alloc = typename Container::allocator_type, int _concept_requires_247 = 42, typename std::enable_if<(_concept_requires_247==43)||(detail::ConvertibleToContainer<D, Container>()), int>::type=0>
operator Container();

Implicit conversion to something that looks like a container.