<commit_before>#ifndef ITER_REVERSE_HPP_
#define ITER_REVERSE_HPP_

#include "iterbase.hpp"

#include <utility>
#include <iterator>

namespace iter {
    template <typename Container>
    class Reverser;

    template <typename Container>
    Reverser<Container> reversed(Container&&);


    template <typename Container>
    class Reverser {
        private:
            Container container;
            friend Reverser reversed<Container>(Container&&);
            
            Reverser(Container&& in_container)
                : container(std::forward<Container>(in_container))
            { }

        public:
            class Iterator : public std::iterator<
                         std::input_iterator_tag,
                         iterator_traits_deref<Container>>
            {
                private:
                    reverse_iterator_type<Container> sub_iter;
                public:
                    Iterator (reverse_iterator_type<Container>&& iter)
                        : sub_iter{std::move(iter)}
                    { } 

                    reverse_iterator_deref<Container> operator*() {
                        return *this->sub_iter;
                    }

                    Iterator& operator++() { 
                        ++this->sub_iter;
                        return *this;
                    }

                    Iterator operator++(int) {
                        auto ret = *this;
                        ++*this;
                        return ret;
                    }

                    bool operator!=(const Iterator& other) const {
                        return this->sub_iter != other.sub_iter;
                    }

                    bool operator==(const Iterator& other) const {
                        return !(*this != other);
                    }
            };

            Iterator begin() {
                return {this->container.rbegin()};
            }

            Iterator end() {
                return {this->container.rend()};
            }

    };

    template <typename Container>
    Reverser<Container> reversed(Container&& container) {
        return {std::forward<Container>(container)};
    }

    //
    // specialization for statically allocated arrays
    //
    template <typename T, std::size_t N>
    Reverser<T[N]> reversed(T (&)[N]);

    template <typename T, std::size_t N>
    class Reverser<T[N]> {
        private:
            T *array;
            friend Reverser reversed<T, N>(T (&)[N]);
            
            // Value constructor for use only in the reversed function
            Reverser(T *in_array)
                : array{in_array}
            { }

        public:
            Reverser(const Reverser&) = default;
            class Iterator : public std::iterator<std::input_iterator_tag, T>
            {
                private:
                    T *sub_iter;
                public:
                    Iterator (T *iter)
                        : sub_iter{iter}
                    { } 

                    iterator_deref<T[N]> operator*() {
                        return *(this->sub_iter - 1);
                    }

                    Iterator& operator++() { 
                        --this->sub_iter;
                        return *this;
                    }

                    Iterator operator++(int) {
                        auto ret = *this;
                        ++*this;
                        return ret;
                    }

                    bool operator!=(const Iterator& other) const {
                        return this->sub_iter != other.sub_iter;
                    }

                    bool operator==(const Iterator& other) const {<commit_msg>adds reversed iter -> and shortens array types<commit_after>#ifndef ITER_REVERSE_HPP_
#define ITER_REVERSE_HPP_

#include "iterbase.hpp"

#include <utility>
#include <iterator>

namespace iter {
    template <typename Container>
    class Reverser;

    template <typename Container>
    Reverser<Container> reversed(Container&&);


    template <typename Container>
    class Reverser {
        private:
            Container container;
            friend Reverser reversed<Container>(Container&&);
            
            Reverser(Container&& in_container)
                : container(std::forward<Container>(in_container))
            { }

        public:
            class Iterator : public std::iterator<
                         std::input_iterator_tag,
                         iterator_traits_deref<Container>>
            {
                private:
                    reverse_iterator_type<Container> sub_iter;
                public:
                    Iterator (reverse_iterator_type<Container>&& iter)
                        : sub_iter{std::move(iter)}
                    { } 

                    reverse_iterator_deref<Container> operator*() {
                        return *this->sub_iter;
                    }

                    reverse_iterator_arrow<Container> operator->() {
                        return apply_arrow(this->sub_iter);
                    }

                    Iterator& operator++() { 
                        ++this->sub_iter;
                        return *this;
                    }

                    Iterator operator++(int) {
                        auto ret = *this;
                        ++*this;
                        return ret;
                    }

                    bool operator!=(const Iterator& other) const {
                        return this->sub_iter != other.sub_iter;
                    }

                    bool operator==(const Iterator& other) const {
                        return !(*this != other);
                    }
            };

            Iterator begin() {
                return {this->container.rbegin()};
            }

            Iterator end() {
                return {this->container.rend()};
            }

    };

    template <typename Container>
    Reverser<Container> reversed(Container&& container) {
        return {std::forward<Container>(container)};
    }

    //
    // specialization for statically allocated arrays
    //
    template <typename T, std::size_t N>
    Reverser<T[N]> reversed(T (&)[N]);

    template <typename T, std::size_t N>
    class Reverser<T[N]> {
        private:
            T *array;
            friend Reverser reversed<T, N>(T (&)[N]);
            
            // Value constructor for use only in the reversed function
            Reverser(T *in_array)
                : array{in_array}
            { }

        public:
            Reverser(const Reverser&) = default;
            class Iterator : public std::iterator<std::input_iterator_tag, T>
            {
                private:
                    T *sub_iter;
                public:
                    Iterator (T *iter)
                        : sub_iter{iter}
                    { } 

                    T& operator*() {
                        return *(this->sub_iter - 1);
                    }

                    T *operator->() {
                        return (this->sub_iter - 1);
                    }

                    Iterator& operator++() { 
                        --this->sub_iter;
                        return *this;
                    }

                    Iterator operator++(int) {
                        auto ret = *this;
                        ++*this;
                        return ret;
                    }

                    bool operator!=(const Iterator& other) const {
                        return this->sub_iter != other.sub_iter;
                    }

                    bool operator==(const Iterator& other) const {
{'fraction_non_alphanumeric': 0.09365637618861535, 'fraction_numerical': 0.00039077764751856197, 'mean_word_length': 1.1058694459681844, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 70, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6147059', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1725, 'n_words': 391}