Consider the following piece of code (out of context for the sake of simplicity):
std::unique_ptr<std::istream> stream;
stream = std::make_unique<std::ifstream>(path, std::ios::in | std::ios::binary);
This code compiles just fine with MSVC and works with no problem, but Clang issues an error:
error: no viable overloaded '='
stream = std::make_unique<std::ifstream>(path, std::ios::in | std::ios::binary);
Alongside with the error above, the log also claims that 'unique_ptr<std::basic_ifstream<char>, default_delete<std::basic_ifstream<char>>>' is not convertable to 'unique_ptr<std::istream, default_delete<std::istream>>'.
I cannot use a reference as I need to keep stream alive outside the current scope, so a pointer seems to be the only solution. How can I solve the problem?