Reading three rows of six tab-separated numbers
the first use can be replaced with:

while(in &gt;&gt; s) {
    data.push_back(s)
}


the second case is much more readable with a simple if else:

std::ifstream f;
if(argc &gt;= 2 &amp;&amp; 0 != strcmp("-", argv[1])) {
    f.open(argv[1]);
    if (!f) {
        std::cerr &lt;&lt; "Error opening " &lt;&lt; argv[1] &lt;&lt; ": "
                  &lt;&lt; strerror(errno) &lt;&lt; std::endl;
        return 1;
    }

}
std::istream &amp;in = f.is_open() ? f : std::cin;