vincentlaucsb / csv-parser

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

Hope to suport for ubuntu 16.04, g++ 5.4.0 #100

Closed zzuse closed 4 years ago

zzuse commented 4 years ago

Hi, Hope to suport for ubuntu 16.04, g++ 5.4.0. Thanks


When using single include files. The compiler will report a bunch of errors, maybe the compiler have bugs. But there are many reason to not upgrade compiler and use on some old platforms.

/usr/include/c++/5/bits/unordered_map.h:649:7: error: 'value' is not a member of 'std::not_<std::_and<std::is_fast_hash<std::hash >, std::detail::is_noexcept_hash<csv::DataType, std::hash > > >' equal_range(const key_type& __x) const ^ ./src/include/csv.hpp: In function 'std::unordered_map<std::__cxx11::basic_string, csv::DataType> csv::csv_data_types(const string&)': ... ... ...

./src/include/csv.hpp:5948:25: error: no match for 'operator[]' (operand types are 'std::unordered_map<csv::DataType, long long int>' and 'csv::DataType') else if (col[CSV_INT8]) ^ ./src/include/csv.hpp:5859:59: error: no matching function for call to 'std::unordered_map<csv::DataType, long long int>::insert(std::pair<csv::DataType, int>)' this->dtypes[i].insert(std::make_pair(type, 1)); ^ I

vincentlaucsb commented 4 years ago

I appreciate your interest in this parser, but I'm more interested in achieving better performance and adding more features. g++-5 is an extremely buggy compiler and it's not my goal to support five year old compilers.

zzuse commented 4 years ago

Thank you, I compiled it, changed some places and maybe lose some performance, but can use now. Hope can help others. version 1.3.3

382d381
< #include <cmath>
4048c4047
<             inline bool operator==(const iterator& other) const {
---
>             constexpr bool operator==(const iterator& other) const {
4052c4051
<             inline bool operator!=(const iterator& other) const { return !operator==(other); }
---
>             constexpr bool operator!=(const iterator& other) const { return !operator==(other); }
4503c4502
< #include <map>
---
> #include <unordered_map>
4516c4515
<         using TypeCount = std::map<DataType, RowCount>;
---
>         using TypeCount = std::unordered_map<DataType, RowCount>;
5886c5885
<         if (std::isnan(this->mins[i]))
---
>         if (isnan(this->mins[i]))
5888c5887
<         if (std::isnan(this->maxes[i]))
---
>         if (isnan(this->maxes[i]))
6117c6116
< #endif
---
> #endif