<commit_before>//=======================================================================
// Copyright (c) 2014-2015 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#ifndef ETL_ITERATOR_HPP
#define ETL_ITERATOR_HPP

#include <iterator>

#include "traits_lite.hpp"

namespace etl {

template<typename Expr, bool Ref = false, bool Const = true>
struct iterator : public std::iterator<std::random_access_iterator_tag, value_t<Expr>> {
private:
    Expr* expr;
    std::size_t i;

public:
    using base_iterator_t = std::iterator<std::random_access_iterator_tag, value_t<Expr>>;
    using value_type = value_t<Expr>;
    using reference_t = std::conditional_t<Ref,
          std::conditional_t<Const, const value_type&, value_type&>,
          value_type>;
    using pointer_t = std::conditional_t<Const, const value_type*, value_type*>;
    using difference_t = typename base_iterator_t::difference_type;

    iterator(Expr& expr, std::size_t i) : expr(&expr), i(i) {}

    reference_t operator*(){
        return (*expr)[i];
    }

    reference_t operator[](difference_t n){
        return (*expr)[n];
    }

    pointer_t operator->(){
        return &(*expr)[i];
    }

    iterator& operator--(){
        --i;
        return *this;
    }

    iterator operator--(int){
        iterator prev(*this);
        --i;
        return prev;
    }

    iterator& operator++(){
        ++i;
        return *this;
    }

    iterator operator++(int){
        iterator prev(*this);
        ++i;
        return prev;
    }

    iterator& operator+=(difference_t n){
        i += n;
        return *this;
    }

    iterator& operator-=(difference_t n){
        i -= n;
        return *this;
    }

    iterator operator+(difference_t n){
        iterator it(*this);
        it += n;
        return it;
    }

    iterator operator-(difference_t n){
        iterator it(*this);
        it -= n;
        return it;
    }

    difference_t operator-(const iterator& it){
        return i - it.i;
    }

    bool operator==(const iterator& other) const {
        return expr == other.expr && i == other.i;
    }

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

} //end of namespace etl

#endif<commit_msg>Make iterator random-access-iterator compliant<commit_after>//=======================================================================
// Copyright (c) 2014-2015 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#ifndef ETL_ITERATOR_HPP
#define ETL_ITERATOR_HPP

#include <iterator>

#include "traits_lite.hpp"

namespace etl {

template<typename Expr, bool Ref = false, bool Const = true>
struct iterator : public std::iterator<std::random_access_iterator_tag, value_t<Expr>> {
private:
    Expr* expr;
    std::size_t i;

public:
    using base_iterator_t = std::iterator<std::random_access_iterator_tag, value_t<Expr>>;
    using value_type = value_t<Expr>;
    using reference_t = std::conditional_t<Ref,
          std::conditional_t<Const, const value_type&, value_type&>,
          value_type>;
    using pointer_t = std::conditional_t<Const, const value_type*, value_type*>;
    using difference_t = typename base_iterator_t::difference_type;

    iterator(Expr& expr, std::size_t i) : expr(&expr), i(i) {}

    reference_t operator*(){
        return (*expr)[i];
    }

    reference_t operator[](difference_t n){
        return (*expr)[n];
    }

    pointer_t operator->(){
        return &(*expr)[i];
    }

    iterator& operator--(){
        --i;
        return *this;
    }

    iterator operator--(int){
        iterator prev(*this);
        --i;
        return prev;
    }

    iterator& operator++(){
        ++i;
        return *this;
    }

    iterator operator++(int){
        iterator prev(*this);
        ++i;
        return prev;
    }

    iterator& operator+=(difference_t n){
        i += n;
        return *this;
    }

    iterator& operator-=(difference_t n){
        i -= n;
        return *this;
    }

    iterator operator+(difference_t n){
        iterator it(*this);
        it += n;
        return it;
    }

    iterator operator-(difference_t n){
        iterator it(*this);
        it -= n;
        return it;
    }

    difference_t operator-(const iterator& it){
        return i - it.i;
    }

    bool operator==(const iterator& other) const {
        return expr == other.expr && i == other.i;
    }

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

    bool operator>(const iterator& other) const {
        return i > other.i;
    }

    bool operator>=(const iterator& other) const {
        return i >= other.i;
    }

    bool operator<(const iterator& other) const {
        return i < other.i;
    }

    bool operator<=(const iterator& other) const {
        return i <= other.i;

    }
};

} //end of namespace etl

#endif
{'fraction_non_alphanumeric': 0.18066255778120185, 'fraction_numerical': 0.0030816640986132513, 'mean_word_length': 2.6037473976405274, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, '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': '3273725', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1502, 'n_words': 394}