This commit is contained in:
Zengtudor 2024-09-16 22:54:56 +08:00
parent ff91daf4b7
commit 1095672253
4 changed files with 79 additions and 0 deletions

3
.gitignore vendored Normal file
View File

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

View File

@ -1,2 +1,17 @@
# VideoShows # VideoShows
## 如何构建?
>请先安装xmake并执行
```bash
xmake -v
xmake r <target name>
```
>即可如果你想用xmake构建可以使用
```bash
xmake project -k xmake
```
>生成CMakeLists.txt

View File

@ -0,0 +1,54 @@
#include <iostream>
#include <sstream>
template<typename ...Args>
void print(const Args&...args){
std::stringstream ss;
((ss<<args),...);
std::cout<<ss.str();
}
template<typename T>
class Range{
private:
T _start,_end,_step;
public:
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)noexcept:Range(start,end,1){}
constexpr Range(const T end)noexcept:Range(1,end,1){}
struct Iterator{
T current,step;
constexpr Iterator()=delete;
constexpr Iterator(const T start,const T step)noexcept:current(start),step(step){}
constexpr bool operator!=(const Iterator &other)const noexcept{
return current<other.current;
}
constexpr Iterator& operator++()noexcept{
current+=step;
return *this;
}
constexpr T operator*()const noexcept{
return current;
}
};
constexpr Iterator begin(){
return Iterator(_start,_step);
}
constexpr Iterator end(){
return Iterator(_end,_step);
}
};
int main(const int argc,const char* argv[]){
for(auto i:Range(1,11,2)){
for(auto j:Range(1,11,2)){
print("[","i: ",i," ,j: ",j,"] ");
}
print("\n");
}
print("\n");
}

7
xmake.lua Normal file
View File

@ -0,0 +1,7 @@
add_rules("mode.debug","mode.release")
set_warnings("all")
set_languages("c++20")
target("printAndRange")
add_files("printAndRange/printAndRange.cpp")