This commit is contained in:
Zengtudor 2024-09-16 18:34:28 +08:00
parent 9c1a74f31a
commit ae4f499db1
3 changed files with 59 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.vscode
.xmake
build

47
src/replaceStr/main.cpp Normal file
View 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");
}

9
xmake.lua Normal file
View File

@ -0,0 +1,9 @@
add_rules("mode.debug","mode.release")
set_languages("c++23")
set_warnings("all")
target("replaceStr")
set_kind("binary")
add_files("./src/replaceStr/*.cpp")