I used to allocate memory in my C++ project with new
char* buffer = new char [size];
...
delete[] buffer;
and I'd really like to move forward and use unique_ptr
, like this
unique_ptr<char[]>buffer(new char[size]);
but then I use istream& get (char* s, streamsize n);
which takes char*
as a first argument, so what should I do? I've tried to cast types, but failed. I also know I can use vector<char>
instead of pointers, but I don't really like to use it. Thank you!