C++ and Enumerable
<p>I have a producer/consumers design in my application which implement Produce/Consume functions on user types. But it doesn't work very naturally with the standard library and especially with algorithms.</p>

<p>In C# there is the Enumerable and Observable concepts that can be used to easily implement stuff like this and get alot of nice free functionality.</p>

<p>In C++ there is the ios, istream, ostream, input_iterator, output_iterator concepts which I thought might be useful. But it seems to me that all of these are for primitive character types, e.g. char, int etc... and not for user types.</p>

<p>Sure I could use real functions such as Produce/Consumer and std::mem_fn for algorithms. But I was hoping there was a better way.</p>

<p>Im looking on some best-practice advice on how to go about designing i/o similar solutions on user types in C++.</p>

<p>E.g. from C#</p>

<pre><code>class FrameProducer : IEnumerable&lt;Frame&gt; // pull frames
{...}

// Some engine between

class FrameConsumer : IObserver&lt;Frame&gt; // push frames
{...}
</code></pre>

<p>I was hoping for something similar in C++ e.g. which i dont believe is possible.</p>

<pre><code>class FrameProducer : istream&lt;Frame&gt; // pull frames
{...}

// Some engine between

class FrameConsumer : ostream&lt;Frame&gt; // push frames
{...}
</code></pre>

<p>Maybe I'm thinking to hard about it and should just go by KISS.</p>

<p>Thoughts?</p>
