diff --git a/include/tmp/path.hpp b/include/tmp/path.hpp index 188e3b3..a33ef50 100644 --- a/include/tmp/path.hpp +++ b/include/tmp/path.hpp @@ -12,6 +12,8 @@ namespace tmp { /// Subclass this and provide mktemp-like function to the constructor to create /// temporary files and directories. class path { + std::filesystem::path underlying; ///< This path + public: /// Returns the underlying path operator const std::filesystem::path&() const noexcept; @@ -28,8 +30,6 @@ class path { auto operator=(const path&) = delete; ///< not copy-assignable protected: - std::filesystem::path underlying; ///< This file path - /// Creates a unique temporary path using the given constructor function. /// @param prefix the path between system temp /// @param creator wrapped mktemp-like function that returns resulting path diff --git a/lib/file.cpp b/lib/file.cpp index 9497f29..fd1c261 100644 --- a/lib/file.cpp +++ b/lib/file.cpp @@ -43,8 +43,8 @@ std::filesystem::path file::create(std::string_view prefix) { std::ofstream file::stream(bool append) const noexcept { std::ios::openmode mode = append ? std::ios::app : std::ios::trunc; return this->binary - ? std::ofstream { this->underlying, mode | std::ios::binary } - : std::ofstream { this->underlying, mode }; + ? std::ofstream { static_cast(*this), mode | std::ios::binary } + : std::ofstream { static_cast(*this), mode }; }; } // namespace tmp