From c138752eccd31061035caaacf70370e6b8cf2dd3 Mon Sep 17 00:00:00 2001 From: Pagwin Date: Wed, 10 Apr 2024 23:49:47 -0400 Subject: [PATCH] began work on istream iterator --- include/pit/iters.h | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/include/pit/iters.h b/include/pit/iters.h index 6e90391..e3dad4b 100644 --- a/include/pit/iters.h +++ b/include/pit/iters.h @@ -1,4 +1,7 @@ #include +#include +#include + namespace pit{ template class passthrough{ @@ -45,13 +48,43 @@ namespace pit{ T val; public: // noops - repeat operator+(std::size_t ){} - repeat 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 Allocator = std::allocator> + class basic_stream_split { + bool ended; + std::basic_istream stream; + + public: + bool operator==(basic_stream_split const& rhs){ + return this->ended == rhs; + } + // todo: +,-, +=, -=, * + }; + + using stream_split = basic_stream_split; + using wstream_split = basic_stream_split; }