Since streams are not copied, you can tecxhnicaly put them in standard containers.
But we can get around this by storing the flow pointers. But you do not want to store stream pointers (especially if they are dynamically allocated) in a standard container. Therefore, we strive to enhance the solution.
Boost has the concept of pointer containers.
This allows you to dynamically allocate the object and store the pointer in a container of the pointer, which then becomes the property of the object and gives you access to the dynamic object as if it were an object (not a pointer).
Since the container pointer takes responsibility, you do not have to worry about deleting the object. The container will do this.
Since it provides access to contained objects as objects, rather than pointers, it allows using the stream in standard algorithms in a more natural fashon (in a camp with a container of pointers).
Martin york
source share