I have a function do_something
that reads unsigned characters from a stream.
The stream can be created from a file given the file name. Or it can be created from the given string by considering it as data. I would like to reuse the function in both cases.
The code below gives an error in the second case: "error C2664: 'do_something: cannot convert argument 1 from 'std::basic_istringstream' to 'std::basic_istream'".
What is the proper way to do this?
static void do_something(std::basic_istream<unsigned char>& in)
{
in.get();
}
static void string_read(unsigned char* in)
{
std::basic_ifstream<unsigned char> file(std::string("filename"));
do_something(file);
std::basic_istringstream<unsigned char> str(std::basic_string<unsigned char>(in));
do_something(str);
}
-Wextra
. – Denman