added a bunch of stuff, repeat needs to change a bit to actually repeat forever
This commit is contained in:
parent
a7e6d1d8de
commit
6dec072a21
2 changed files with 57 additions and 0 deletions
|
@ -0,0 +1,57 @@
|
||||||
|
#include <cstdlib>
|
||||||
|
namespace pit{
|
||||||
|
template<typename T>
|
||||||
|
class passthrough{
|
||||||
|
T underlying;
|
||||||
|
public:
|
||||||
|
passthrough<T>(T underlying): underlying(underlying){}
|
||||||
|
passthrough<T>(passthrough<T>& from): underlying(from.underlying){}
|
||||||
|
passthrough<T> operator+(std::size_t amount){
|
||||||
|
return passthrough<T>(this->underlying+amount);
|
||||||
|
}
|
||||||
|
void operator+=(std::size_t amount){
|
||||||
|
this->underlying += amount;
|
||||||
|
}
|
||||||
|
passthrough<T> operator-(std::size_t amount){
|
||||||
|
return passthrough<T>(this->underlying-amount);
|
||||||
|
}
|
||||||
|
void operator-=(std::size_t amount){
|
||||||
|
this->underlying -= amount;
|
||||||
|
}
|
||||||
|
T const& operator*(){
|
||||||
|
return this->underlying;
|
||||||
|
}
|
||||||
|
bool operator==(passthrough<T> const& rhs){
|
||||||
|
return this->underlying == rhs.underlying;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<typename T>
|
||||||
|
class range{
|
||||||
|
private:
|
||||||
|
T beginning;
|
||||||
|
T ending;
|
||||||
|
public:
|
||||||
|
range<T>(T begin, T end):beginning(begin), ending(end){}
|
||||||
|
passthrough<T> begin(){
|
||||||
|
return passthrough<T>(this->beginning);
|
||||||
|
}
|
||||||
|
passthrough<T> end(){
|
||||||
|
return passthrough<T>(this->ending);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class repeat{
|
||||||
|
T val;
|
||||||
|
public:
|
||||||
|
// noops
|
||||||
|
repeat<T> operator+(std::size_t ){}
|
||||||
|
repeat<T> operator-(std::size_t ){}
|
||||||
|
void operator+=(std::size_t ){}
|
||||||
|
void operator-=(std::size_t ){}
|
||||||
|
bool operator==(repeat const& rhs){return true;}
|
||||||
|
T const& operator*(){
|
||||||
|
return this->val;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue