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.
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.
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.
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.
Im looking on some best-practice advice on how to go about designing i/o similar solutions on user types in C++.
E.g. from C#
class FrameProducer : IEnumerable<Frame> // pull frames
{...}
// Some engine between
class FrameConsumer : IObserver<Frame> // push frames
{...}
I was hoping for something similar in C++ e.g. which i dont believe is possible.
class FrameProducer : istream<Frame> // pull frames
{...}
// Some engine between
class FrameConsumer : ostream<Frame> // push frames
{...}
Maybe I'm thinking to hard about it and should just go by KISS.
Thoughts?