6
This commit is contained in:
@@ -2,16 +2,21 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
|
||||
namespace aocpp {
|
||||
|
||||
auto Startup(int argc, char ** argv) -> std::ifstream {
|
||||
if (argc != 2) {
|
||||
std::cerr << "Expected input file argument\n";
|
||||
auto Startup(int argc, char ** argv) -> std::istream& {
|
||||
static std::ifstream fin;
|
||||
switch (argc) {
|
||||
case 2: fin = std::ifstream{argv[1]}; return fin;
|
||||
case 1: return std::cin;
|
||||
default:
|
||||
std::cerr << "bad arguments\n";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return std::ifstream{argv[1]};
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user