C++ I/O class templates for handling a memory buffer as the source/sink