I am used to writing little command line tools that take either a file name or read from std::cin, so I have been using this pattern for quite a while:
The compiler tries to find a common type for both result from the ternary operator, and if you see e.g. this reference you will see there is a casting operator override for void* (or bool for C++11 and later), so the compiler uses that.
But then when it tries to do the assignment, it errors out because on the right-hand side of the initialization you have a void* (alternatively bool) type, and on the left-hand side there's a reference to std::istream.
To solve it you have to manually cast each stream to a reference to std::istream with e.g. static_cast.