Creating an input stream from constant memory
The way to do this is to create a suitable stream buffer. This can, e.g., be done like this: #include <streambuf> #include <istream> struct membuf: std::streambuf { membuf(char const* base, size_t size) { char* p(const_cast<char*>(base)); this->setg(p, p, p + size); } }; struct imemstream: virtual membuf, std::istream { imemstream(char const* base, size_t size) : membuf(base, … Read more