22 std::string report_failed_read(
const std::filesystem::path& file);
25 std::string report_failed_write(
const std::filesystem::path& file);
29 std::optional<std::string> read_to_string(
const std::filesystem::path& file);
31 void write_to_file(
const std::filesystem::path& file, std::string_view text, std::ios_base::openmode mode=std::ios_base::out);
33 template<std::invocable<std::
string&> Fn>
34 void read_modify_write(
const std::filesystem::path& file, Fn fn)
36 if(
auto text{read_to_string(file)})
39 write_to_file(file, *text);
43 throw std::runtime_error{report_failed_read(file)};
Concepts which are sufficiently general to appear in the sequoia namespace.