Hi,

This might be more a C++ question, but I'm trying to have one variable
store the output stream for both StdoutStream and FileOutputStream. I do
this:

shared_ptr<OutputStream> f;
if (fn == "stdout")
    f.reset(new StdoutStream());
else
    FileOutputStream::Open(fn, false, &f);

As is, the code does not work because Open expects
shared_ptr<FileOutputStream>. If I do a cast:

FileOutputStream::Open(fn, false,
    &(dynamic_pointer_cast<FileOutputStream>(f)));

I get an error: taking address of temporary [-fpermissive]

What would be a good way of having one variable for both branches of the if
statement?

Thanks!
Rares

Reply via email to