diff --git a/io.cpp b/io.cpp index a71d7fc7..6cc8ba22 100644 --- a/io.cpp +++ b/io.cpp @@ -38,14 +38,12 @@ template std::vector util::slurp (const std::experimental::filesystem::path &path) { - static_assert ( - sizeof (T) == 1, - "slurp is designed for grabbing bytes, not complex structures" - ); posix::fd out (path, O_RDONLY | O_BINARY); // Calculate the total file size off_t size = posix::error::try_value (lseek (out, 0, SEEK_END)); + if (size % sizeof (T)) + throw std::runtime_error ("filesize not correctly rounded"); posix::error::try_value (lseek (out, 0, SEEK_SET)); @@ -75,6 +73,7 @@ util::slurp (const std::experimental::filesystem::path &path) //----------------------------------------------------------------------------- template std::vector util::slurp (const std::experimental::filesystem::path&); template std::vector util::slurp (const std::experimental::filesystem::path&); +template std::vector util::slurp (const std::experimental::filesystem::path&); ///////////////////////////////////////////////////////////////////////////////