57 lines
1.6 KiB
C++
57 lines
1.6 KiB
C++
#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;
|
|
}
|
|
};
|
|
}
|