Skip to content

Commit 68460c2

Browse files
committed
drop broken move constructor in zip_sink
1 parent b1149ff commit 68460c2

File tree

4 files changed

+14
-36
lines changed

4 files changed

+14
-36
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
cmake_minimum_required ( VERSION 2.8.12 )
1616

1717
project ( staticlib_compress CXX )
18-
set ( ${PROJECT_NAME}_STATICLIB_VERSION 1.2.1 )
18+
set ( ${PROJECT_NAME}_STATICLIB_VERSION 1.2.2 )
1919
set ( ${PROJECT_NAME}_DESCRIPTION "Staticlibs Compress library" )
2020
set ( ${PROJECT_NAME}_URL https://github.com/staticlibs/staticlib_compress )
2121
include ( ${CMAKE_CURRENT_LIST_DIR}/resources/macros.cmake )

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ This project is released under the [Apache License 2.0](http://www.apache.org/li
2626
Changelog
2727
---------
2828

29+
**2018-05-16**
30+
31+
* version 1.2.2
32+
* drop broken move constructor in `zip_sink`
33+
2934
**2018-02-22**
3035

3136
* version 1.2.1

include/staticlib/compress/zip_sink.hpp

+6-33
Original file line numberDiff line numberDiff line change
@@ -239,35 +239,6 @@ class zip_sink {
239239
*/
240240
zip_sink& operator=(const zip_sink&) = delete;
241241

242-
/**
243-
* Move constructor
244-
*
245-
* @param other other instance
246-
*/
247-
zip_sink(zip_sink&& other) :
248-
sink(std::move(other.sink)),
249-
headers(std::move(other.headers)),
250-
cd_written(other.cd_written),
251-
entry_counter(std::move(other.entry_counter)),
252-
entry_deflater(std::move(other.entry_deflater)),
253-
entry_crc(other.entry_crc) { }
254-
255-
/**
256-
* Move assignment operator
257-
*
258-
* @param other other instance
259-
* @return this instance
260-
*/
261-
zip_sink& operator=(zip_sink&& other) {
262-
sink = std::move(other.sink);
263-
headers = std::move(other.headers);
264-
cd_written = other.cd_written;
265-
entry_counter = std::move(other.entry_counter);
266-
entry_deflater = std::move(other.entry_deflater);
267-
entry_crc = other.entry_crc;
268-
return *this;
269-
}
270-
271242
/**
272243
* Write implementation
273244
*
@@ -354,8 +325,9 @@ class zip_sink {
354325
*/
355326
template <typename Sink,
356327
class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
357-
zip_sink<Sink> make_zip_sink(Sink&& sink) {
358-
return zip_sink<Sink>(std::move(sink));
328+
sl::io::unique_sink<zip_sink<Sink>> make_zip_sink(Sink&& sink) {
329+
auto ptr = new zip_sink<Sink>(std::move(sink));
330+
return sl::io::make_unique_sink(ptr);
359331
}
360332

361333
/**
@@ -366,9 +338,10 @@ zip_sink<Sink> make_zip_sink(Sink&& sink) {
366338
* @return zip sink
367339
*/
368340
template <typename Sink>
369-
zip_sink<sl::io::reference_sink<Sink>> make_zip_sink(Sink& sink) {
370-
return zip_sink<sl::io::reference_sink<Sink>> (
341+
sl::io::unique_sink<zip_sink<sl::io::reference_sink<Sink>>> make_zip_sink(Sink& sink) {
342+
auto ptr = new zip_sink<sl::io::reference_sink<Sink>> (
371343
sl::io::make_reference_sink(sink));
344+
return sl::io::make_unique_sink(ptr);
372345
}
373346

374347
} // namespace

test/zip_sink_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
void test_store() {
3434
auto sink = sl::compress::make_zip_sink(sl::tinydir::file_sink("test.zip"));
35-
sink.add_entry("foo.txt");
35+
sink.get_sink().add_entry("foo.txt");
3636
sink.write({"hello", 5});
37-
sink.add_entry("bar/baz.txt");
37+
sink.get_sink().add_entry("bar/baz.txt");
3838
sink.write({"bye", 3});
3939
}
4040

0 commit comments

Comments
 (0)