This smells like an XY problem, because here you don't need a triple conditional link or link.
As a rule, many programs use - to indicate stdin , and not to refuse the file name. This is one of the possible ways. In a similar thought, I used Boost.ProgramOptions or getopt instead of manually parsing the command line. This will indirectly solve your XY problem, as it will make the FileIsProvided() function redundant, and you will get your parameters using other methods than directly using argv[1] .
If you have C ++ 11, there are smart pointers or std::reference_wrapper , which allows you to "reset" the links.
As an anti-motivator, consider classes like ostream_joiner to keep a pointer to their internal stream objects, not a link. Also, I doubt that you like to think about dealing with dangling links from harmless looking code.
Otherwise...
if (FileIsProvided()) { std::ifstream ifs(argv[1]); if (ifs) { ProcessStream(ifs); } } else { ProcessStream(std::cin); }
uh oh somebody needs a pupper
source share