diff --git a/lib/src/Startup.cpp b/lib/src/Startup.cpp index fc5721c..78aaa81 100644 --- a/lib/src/Startup.cpp +++ b/lib/src/Startup.cpp @@ -2,10 +2,9 @@ #include #include -#include -#include #include #include + #include #define DOCTEST_CONFIG_IMPLEMENT @@ -41,27 +40,22 @@ auto main(int argc, char ** argv) -> int return doctest::Context{argc, argv}.run(); } - std::unique_ptr in - {in_name - ? decltype(in){new std::ifstream{in_name}, [](auto p) { delete p; }} - : decltype(in){&std::cin, [](auto){}}}; + std::ifstream fin; + std::ofstream fout; + std::istream & in {in_name ? fin = std::ifstream{in_name } : std::cin }; + std::ostream & out {out_name ? fout = std::ofstream{out_name} : std::cout}; - if (in->fail()) { + if (in.fail()) { std::cerr << "Bad input file" << std::endl; return 1; } - std::unique_ptr out - {out_name - ? decltype(out){new std::ofstream{out_name}, [](auto p) { delete p; }} - : decltype(out){&std::cout, [](auto){}}}; - - if (out->fail()) { + if (out.fail()) { std::cerr << "Bad output file" << std::endl; return 1; } - Main(*in, *out); + Main(in, out); } catch (std::exception const& e) { std::cerr << "Program failed: " << e.what() << std::endl; return 1;