main.cpp (1184B)
1 #include <iostream> 2 #include <filesystem> 3 #include <fstream> 4 #include <vector> 5 #include <cstring> 6 #include <cstdio> 7 #include <tuple> 8 #include <algorithm> 9 10 template<typename T> 11 T read_file(const std::string &path) { 12 std::ifstream ifs(path, std::ios::binary); 13 if (!ifs.is_open()) { 14 throw std::runtime_error(path+":"+std::strerror(errno)); 15 } 16 //std::uintmax_t size = std::filesystem::file_size(path); 17 T buf; 18 /*while (1) { 19 std::string str; 20 std::getline(ifs, str); 21 if (!str.empty()) buf.push_back(Box(str)); 22 if (!ifs) break; 23 }*/ 24 /*if (!ifs.read((char *)buf.data(), buf.size())) { 25 throw std::runtime_error(path+":"+std::strerror(errno)); 26 }*/ 27 return buf; 28 } 29 30 int part1(Data &input [[maybe_unused]]) { 31 return 0; 32 } 33 int part2(Data &input [[maybe_unused]]) { 34 return 0; 35 } 36 37 int main(int argc, char **argv) { 38 const std::string fname = argc>1 ? argv[1] : "test1.txt"; 39 std::cout << "AoC 2015 day $DAY " << fname << std::endl; 40 Data input = read_file<Data>(fname); 41 std::cout << "part1: " << part1(input) << std::endl; 42 std::cout << "part2: " << part2(input) << std::endl; 43 44 return 0; 45 }