This commit is contained in:
Zengtudor 2024-09-17 13:31:49 +08:00
parent 3f256ef270
commit 92a433ed69

View File

@ -10,7 +10,7 @@ namespace zt {
template<typename T> template<typename T>
class Range{ class Range{
private: private:
T _start,_end,_step; const T _start,_end,_step;
public: public:
constexpr Range()=delete; constexpr Range()=delete;
constexpr Range(const T start,const T end,const T step)noexcept:_start(start),_end(end),_step(step){} constexpr Range(const T start,const T end,const T step)noexcept:_start(start),_end(end),_step(step){}
@ -18,7 +18,9 @@ namespace zt {
constexpr Range(const T end)noexcept:Range(1,end,1){} constexpr Range(const T end)noexcept:Range(1,end,1){}
struct Iterator{ struct Iterator{
T current,step; T current;
const T step;
constexpr Iterator()=delete; constexpr Iterator()=delete;
constexpr Iterator(const T start,const T step)noexcept:current(start),step(step){} constexpr Iterator(const T start,const T step)noexcept:current(start),step(step){}
constexpr bool operator!=(const Iterator &other)const noexcept{ constexpr bool operator!=(const Iterator &other)const noexcept{
@ -33,10 +35,10 @@ namespace zt {
} }
}; };
constexpr Iterator begin(){ constexpr Iterator begin()const{
return Iterator(_start,_step); return Iterator(_start,_step);
} }
constexpr Iterator end(){ constexpr Iterator end()const{
return Iterator(_end,_step); return Iterator(_end,_step);
} }
}; };