began work on istream iterator
This commit is contained in:
parent
3ae46c98e0
commit
c138752ecc
1 changed files with 36 additions and 3 deletions
|
@ -1,4 +1,7 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <string>
|
||||||
|
#include <istream>
|
||||||
|
|
||||||
namespace pit{
|
namespace pit{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class passthrough{
|
class passthrough{
|
||||||
|
@ -45,13 +48,43 @@ namespace pit{
|
||||||
T val;
|
T val;
|
||||||
public:
|
public:
|
||||||
// noops
|
// noops
|
||||||
repeat<T> operator+(std::size_t ){}
|
repeat operator+(std::size_t ){}
|
||||||
repeat<T> operator-(std::size_t ){}
|
repeat operator-(std::size_t ){}
|
||||||
void operator+=(std::size_t ){}
|
void 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;}
|
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;
|
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>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue