#pragma once
#ifndef __TMPL_H_
#define __TMPL_H_
#include <iterator>
template <typename T = int>
class range
{
private:
    class range_iterator : std::iterator<std::forward_iterator_tag, T>
    {
    private:
        T val, step;
    public:
        range_iterator(T x, T sp) : val(x), step(sp) {}
        bool operator==(const range_iterator &rhs) const noexcept
        {
            if (step > 0) return val - step < rhs.val && val >= rhs.val;
            if (step < 0) return val - step > rhs.val && val <= rhs.val;
            return val == rhs.val;
        }
        bool operator!=(const range_iterator &rhs) const noexcept { return !(*this == rhs); }
        const auto &operator++() { return val += step, *this; }
        T &operator*() { return val; }
    } st, ed;

public:
    range(T ed) : range(0, ed, 1) {}
    range(T st, T ed, T sp = 1) : st(st, sp), ed(ed, sp) {}
    const range_iterator &begin() { return st; }
    const range_iterator &end() { return ed; }
};
#endif