26 void save(
const std::filesystem::path& filePath,
29 std::ofstream ofs(filePath, std::ios::binary);
31 throw std::runtime_error(
"Cannot open file for writing: " + filePath.string());
34 cereal::BinaryOutputArchive archive(ofs);
35 archive(cereal::make_nvp(
"model", model));
46 std::shared_ptr<MODEL> load(
const std::filesystem::path &filePath )
48 std::ifstream ifs(filePath, std::ios::binary);
50 throw std::runtime_error(
"Cannot open file for reading: " + filePath.string());
52 auto loaded = std::make_shared<MODEL>();
54 cereal::BinaryInputArchive archive(ifs);
55 archive(cereal::make_nvp(
"model", *loaded));