From 37c22a61a234fa32edc3842787c51f5adb9aa62d Mon Sep 17 00:00:00 2001 From: Delaney Sullivan Date: Tue, 25 Apr 2023 22:17:10 -0700 Subject: [PATCH] update zstr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gets rid of error: error: use of deleted function ‘std::basic_istream& std::basic_istream::operator=(const std::basic_istream&)’ std::istream::operator=(std::istream(new istreambuf(_fs.rdbuf()))); --- src/zstr.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/zstr.hpp b/src/zstr.hpp index c6cfacb..8d06370 100755 --- a/src/zstr.hpp +++ b/src/zstr.hpp @@ -14,9 +14,16 @@ #include #include #include - #include "strict_fstream.hpp" +#if defined(__GNUC__) && !defined(__clang__) +#if (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__>0) +#define CAN_MOVE_IOSTREAM +#endif +#else +#define CAN_MOVE_IOSTREAM +#endif + namespace zstr { @@ -424,10 +431,12 @@ class ifstream void close() { _fs.close(); } + #ifdef CAN_MOVE_IOSTREAM void open(const std::string filename, std::ios_base::openmode mode = std::ios_base::in) { _fs.open(filename, mode); std::istream::operator=(std::istream(new istreambuf(_fs.rdbuf()))); } + #endif bool is_open() const { return _fs.is_open(); } @@ -461,11 +470,13 @@ class ofstream std::ostream::flush(); _fs.close(); } + #ifdef CAN_MOVE_IOSTREAM void open(const std::string filename, std::ios_base::openmode mode = std::ios_base::out, int level = Z_DEFAULT_COMPRESSION) { flush(); _fs.open(filename, mode | std::ios_base::binary); std::ostream::operator=(std::ostream(new ostreambuf(_fs.rdbuf(), default_buff_size, level))); } + #endif bool is_open() const { return _fs.is_open(); } @@ -488,4 +499,3 @@ class ofstream }; // class ofstream } // namespace zstr -