| 82 | |
| 83 | template <typename T> |
| 84 | std::shared_ptr<T> load_object_from_file ( |
| 85 | const std::string& filename |
| 86 | ) |
| 87 | /*! |
| 88 | ensures |
| 89 | - deserializes an object of type T from the given file and returns it. |
| 90 | !*/ |
| 91 | { |
| 92 | std::ifstream fin(filename.c_str(), std::ios::binary); |
| 93 | if (!fin) |
| 94 | throw dlib::error("Unable to open " + filename); |
| 95 | auto obj = std::make_shared<T>(); |
| 96 | deserialize(*obj, fin); |
| 97 | return obj; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | // ---------------------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected