began work on istream iterator

This commit is contained in:
Pagwin 2024-04-10 23:49:47 -04:00
parent 3ae46c98e0
commit c138752ecc

View file

@ -1,4 +1,7 @@
#include <cstdlib>
#include <string>
#include <istream>
namespace pit{
template<typename T>
class passthrough{
@ -45,13 +48,43 @@ namespace pit{
T val;
public:
// noops
repeat<T> operator+(std::size_t ){}
repeat<T> operator-(std::size_t ){}
repeat operator+(std::size_t ){}
repeat operator-(std::size_t ){}
void operator+=(std::size_t ){}
void operator-=(std::size_t ){}
// always return false on equality to ensure it repeats forever
bool operator==(repeat const& rhs){return false;}
T const& operator*(){
// if T isn't copyable then make the template arg a reference
T operator*(){
return this->val;
}
// convenience for for loops and what not
repeat begin(){
return *this;
}
repeat end(){
return *this;
}
repeat rbegin(){
return *this;
}
repeat rend(){
return *this;
}
};
template<class CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
class basic_stream_split {
bool ended;
std::basic_istream<CharT, Traits> stream;
public:
bool operator==(basic_stream_split const& rhs){
return this->ended == rhs;
}
// todo: +,-, +=, -=, *
};
using stream_split = basic_stream_split<char>;
using wstream_split = basic_stream_split<wchar_t>;
}