vincentlaucsb / csv-parser

A high-performance, fully-featured CSV parser and serializer for modern C++.
MIT License
901 stars 150 forks source link

wrap RowCollection into unique_ptr #160

Closed artpaul closed 3 years ago

artpaul commented 3 years ago

Currently, with clang 11 the following problem exists:

In file included from /home/paul/dev/github/artpaul/csv-parser/include/internal/csv_reader.cpp:5:
/home/paul/dev/github/artpaul/csv-parser/include/internal/csv_reader.hpp:136:20: warning: explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]
        CSVReader& operator=(CSVReader&& other) = default;
                   ^
/home/paul/dev/github/artpaul/csv-parser/include/internal/csv_reader.hpp:202:23: note: move assignment operator of 'CSVReader' is implicitly deleted because field 'records' has a deleted move assignment operator
        RowCollection records = RowCollection(100);
                      ^
/home/paul/dev/github/artpaul/csv-parser/include/internal/basic_csv_parser.hpp:177:24: note: copy assignment operator of 'ThreadSafeDeque<csv::CSVRow>' is implicitly deleted because field '_lock' has a deleted copy assignment operator
            std::mutex _lock;
                       ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/std_mutex.h:95:12: note: 'operator=' has been explicitly marked deleted here
    mutex& operator=(const mutex&) = delete;
           ^
1 warning generated.

The std::unique_ptr has a trivial move semantic, so by replacing RowCollection with std::unique_ptr we will avoid all this strange mess.

artpaul commented 3 years ago

Fixes #153

vincentlaucsb commented 3 years ago

This makes a lot of sense. Not sure why I didn't do this earlier. Thank you for your PR.