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