diff --git a/include/internal/csv_writer.hpp b/include/internal/csv_writer.hpp index 080acde..fa9b86f 100644 --- a/include/internal/csv_writer.hpp +++ b/include/internal/csv_writer.hpp @@ -5,6 +5,7 @@ #pragma once #include #include +#include #include #include #include @@ -205,7 +206,11 @@ namespace csv { * * @param[out] filename File to write to */ - DelimWriter(const std::string& filename) : DelimWriter(std::ifstream(filename)) {}; + DelimWriter(const std::string& filename) + : inner_os(new std::ofstream(filename)) + , out(*inner_os) + , quote_minimal(true) + {} /** Destructor will flush remaining data * @@ -360,6 +365,7 @@ namespace csv { IF_CONSTEXPR(Flush) out.flush(); } + std::unique_ptr inner_os; OutputStream & out; bool quote_minimal; }; diff --git a/single_include/csv.hpp b/single_include/csv.hpp index 5da087f..8dd2b64 100644 --- a/single_include/csv.hpp +++ b/single_include/csv.hpp @@ -6524,6 +6524,7 @@ namespace csv { #include #include +#include #include #include #include @@ -6722,7 +6723,11 @@ namespace csv { * * @param[out] filename File to write to */ - DelimWriter(const std::string& filename) : DelimWriter(std::ifstream(filename)) {}; + DelimWriter(const std::string& filename) + : inner_os(new std::ofstream(filename)) + , out(*inner_os) + , quote_minimal(true) + {} /** Destructor will flush remaining data * @@ -6877,6 +6882,7 @@ namespace csv { IF_CONSTEXPR(Flush) out.flush(); } + std::unique_ptr inner_os; OutputStream & out; bool quote_minimal; }; diff --git a/single_include_test/csv.hpp b/single_include_test/csv.hpp index 5da087f..8dd2b64 100644 --- a/single_include_test/csv.hpp +++ b/single_include_test/csv.hpp @@ -6524,6 +6524,7 @@ namespace csv { #include #include +#include #include #include #include @@ -6722,7 +6723,11 @@ namespace csv { * * @param[out] filename File to write to */ - DelimWriter(const std::string& filename) : DelimWriter(std::ifstream(filename)) {}; + DelimWriter(const std::string& filename) + : inner_os(new std::ofstream(filename)) + , out(*inner_os) + , quote_minimal(true) + {} /** Destructor will flush remaining data * @@ -6877,6 +6882,7 @@ namespace csv { IF_CONSTEXPR(Flush) out.flush(); } + std::unique_ptr inner_os; OutputStream & out; bool quote_minimal; };