update
This commit is contained in:
parent
9c1a74f31a
commit
ae4f499db1
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.vscode
|
||||
.xmake
|
||||
build
|
47
src/replaceStr/main.cpp
Normal file
47
src/replaceStr/main.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include <iostream>
|
||||
#include<sstream>
|
||||
|
||||
template<typename ...Args>
|
||||
void print(const Args&...args){
|
||||
std::stringstream ss;
|
||||
((ss<<args),...);
|
||||
std::cout<<ss.str();
|
||||
return;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
class Range{
|
||||
private:
|
||||
T _start,_end,_step;
|
||||
public:
|
||||
Range(const T start,const T end){Range(start,end,1);}
|
||||
Range(const T start,const T end,const T step):_start(start),_end(end),_step(step){}
|
||||
|
||||
struct Iterator{
|
||||
T current;
|
||||
T step;
|
||||
Iterator()=delete;
|
||||
Iterator(const T start)noexcept{Iterator(start,1);}
|
||||
Iterator(const T start,const T step)noexcept:current(start),step(step){}
|
||||
bool operator!=(const Iterator &other)const noexcept{
|
||||
return current<other.current;
|
||||
}
|
||||
Iterator& operator++()noexcept{
|
||||
current+=step;
|
||||
return *this;
|
||||
}
|
||||
T operator*(){
|
||||
return current;
|
||||
}
|
||||
};
|
||||
|
||||
Iterator begin()const noexcept{return Iterator(_start,_step);}
|
||||
Iterator end()const noexcept{return Iterator(_end,_step);}
|
||||
};
|
||||
|
||||
int main(const int argc,const char *argv[]){
|
||||
for(auto i:Range(1,11)){
|
||||
print(i," ");
|
||||
}
|
||||
print("\n");
|
||||
}
|
Loading…
Reference in New Issue
Block a user