I'm trying to create a memory stream object to write to a block of memory as if it's a file (using the convenient functionality provided by std::istream). The basic idea is to create a bunch of wrappers for the std::streambuf class.
The issue seems to be that I'm using the std::istream constructor incorrectly. C++ is complaining that I'm referencing a deleted function.
I'm not quite sure what's wrong with the syntax.
inputStream.h
struct IMemBuf : std::streambuf
{
IMemBuf(const char* base, size_t size);
};
struct IMemStream : virtual IMemBuf, std::istream
{
IMemStream(const char* base, size_t size);
};
inputStream.cpp
IMemBuf::IMemBuf(const char* base, size_t size)
{
char* p(const_cast<char*>(base));
this->setg(p, p, p + size);
}
IMemStream::IMemStream(const char* base, size_t size) : IMemBuf(base,size), std::istream(static_cast<std::streambuf*>(this))
{
}
The exact error message is the following:
'IMemStream::IMemStream(const IMemStream &)': attempting to reference a deleted function