ben-strasser / fast-cpp-csv-parser

fast-cpp-csv-parser
BSD 3-Clause "New" or "Revised" License
2.11k stars 440 forks source link

'on_overflow' is not a member of 'io::single_line_comment<'#'>' #68

Closed awgn closed 6 years ago

awgn commented 6 years ago

Enabling C++11 and the single_line_comment policy, we get the following compiler errors:

/opt/tools/csv/./csv.hpp: In instantiation of 'void io::detail::parse_signed_integer(const char, T&) [with overflow_policy = io::single_line_comment<'#'>; T = int]': /opt/tools/csv/./csv.hpp:1018:63: required from 'void io::detail::parse(char, int&) [with overflow_policy = io::single_line_comment<'#'>]' /opt/tools/csv/./csv.hpp:1219:85: required from 'void io::CSVReader<column_count, trim_policy, quote_policy, overflow_policy, comment_policy>::parse_helper(std::size_t, T&, ColType& ...) [with T = int; ColType = {std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::cxx11::basic_string<char, std::char_traits, std::allocator >}; unsigned int column_count = 3u; trim_policy = io::trim_chars<' ', '\011'>; quote_policy = io::double_quote_escape<',', '\''>; overflow_policy = io::single_line_comment<'#'>; comment_policy = io::no_comment; std::size_t = long unsigned int]' /opt/tools/csv/./csv.hpp:1253:53: required from 'bool io::CSVReader<column_count, trim_policy, quote_policy, overflow_policy, comment_policy>::read_row(ColType& ...) [with ColType = {int, std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::cxx11::basic_string<char, std::char_traits, std::allocator >}; unsigned int column_count = 3u; trim_policy = io::trim_chars<' ', '\011'>; quote_policy = io::double_quote_escape<',', '\''>; overflow_policy = io::single_line_comment<'#'>; comment_policy = io::no_comment]' /opt/tools/csv/csv-to-bin.cpp:47:49: required from here /opt/tools/csv/./csv.hpp:999:86: error: 'on_underflow' is not a member of 'io::single_line_comment<'#'>' overflow_policy::on_underflow(x);


/opt/tools/csv/./csv.hpp: In instantiation of 'void io::detail::parse_unsigned_integer(const char*, T&) [with overflow_policy = io::single_line_comment<'#'>; T = unsigned int]':
/opt/tools/csv/./csv.hpp:983:65:   required from 'void io::detail::parse(char*, unsigned int&) [with overflow_policy = io::single_line_comment<'#'>]'
/opt/tools/csv/./csv.hpp:1219:85:   required from 'void io::CSVReader<column_count, trim_policy, quote_policy, overflow_policy, comment_policy>::parse_helper(std::size_t, T&, ColType& ...) [with T = unsigned int; ColType = {int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; unsigned int column_count = 3u; trim_policy = io::trim_chars<' ', '\011'>; quote_policy = io::double_quote_escape<',', '\''>; overflow_policy = io::single_line_comment<'#'>; comment_policy = io::no_comment; std::size_t = long unsigned int]'
/opt/tools/csv/./csv.hpp:1253:53:   required from 'bool io::CSVReader<column_count, trim_policy, quote_policy, overflow_policy, comment_policy>::read_row(ColType& ...) [with ColType = {unsigned int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; unsigned int column_count = 3u; trim_policy = io::trim_chars<' ', '\011'>; quote_policy = io::double_quote_escape<',', '\''>; overflow_policy = io::single_line_comment<'#'>; comment_policy = io::no_comment]'
/opt/tools/csv/csv-to-bin.cpp:92:54:   required from here
/opt/tools/csv/./csv.hpp:968:77: error: 'on_overflow' is not a member of 'io::single_line_comment<'#'>'
                                                 overflow_policy::on_overflow(x);

- clang++-6.0

/opt/tool/csv/./csv.hpp:999:74: error: no member named 'on_underflow' in 'io::single_line_comment<'#'>'
                                                        overflow_policy::on_underflow(x);
                                                        ~~~~~~~~~~~~~~~~~^
/opt/tools/csv/./csv.hpp:1018:26: note: in instantiation of function template specialization 'io::detail::parse_signed_integer<io::single_line_comment<'#'>, int>' requested here
                        {parse_signed_integer<overflow_policy>(col, x);}
                         ^
/opt/tools/csv/./csv.hpp:1219:63: note: in instantiation of function template specialization 'io::detail::parse<io::single_line_comment<'#'> >' requested here
                                                ::io::detail::parse<overflow_policy>(row[r], t);
                                                              ^
/opt/tools/csv/./csv.hpp:1253:41: note: in instantiation of function template specialization 'io::CSVReader<3, io::trim_chars<' ', '\t'>, io::double_quote_escape<',', '\''>, io::single_line_comment<'#'>,
      io::no_comment>::parse_helper<int, std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >' requested here
                                        parse_helper(0, cols...);
                                        ^
/opt/tools/csv/csv-to-bin.cpp:47:22: note: in instantiation of function template specialization 'io::CSVReader<3, io::trim_chars<' ', '\t'>, io::double_quote_escape<',', '\''>, io::single_line_comment<'#'>,
      io::no_comment>::read_row<int, std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >' requested here
ben-strasser commented 6 years ago

Hi,

it would be useful if you would provide a minimal example that triggers the problem. My guess is that you are using the interface wrongly: io::single_line_comment is no overflow_policy. However, the error messages suggest that you use it as such.

Best Regards Dr. Ben Strasser

On 07/07/2018 09:24 AM, Nicola Bonelli wrote:

Enabling C++11 and the single_line_comment policy, we get the following compiler errors:

  • g++-6.3

/opt/tools/csv/./csv.hpp: In instantiation of 'void io::detail::parse_signed_integer(const char, T&) [with overflow_policy = io::single_line_comment<'#'>; T = int]': /opt/tools/csv/./csv.hpp:1018:63: required from 'void io::detail::parse(char, int&) [with overflow_policy = io::single_line_comment<'#'>]' /opt/tools/csv/./csv.hpp:1219:85: required from 'void io::CSVReader<column_count, trim_policy, quote_policy, overflow_policy, comment_policy>::parse_helper(std::size_t, T&, ColType& ...) [with T = int; ColType = {std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::cxx11::basic_string<char, std::char_traits, std::allocator >}; unsigned int column_count = 3u; trim_policy = io::trim_chars<' ', '\011'>; quote_policy = io::double_quote_escape<',', '''>; overflow_policy = io::single_line_comment<'#'>; comment_policy = io::no_comment; std::size_t = long unsigned int]' /opt/tools/csv/./csv.hpp:1253:53: required from 'bool io::CSVReader<column_count, trim_policy, quote_policy, overflow_policy, comment_policy>::read_row(ColType& ...) [with ColType = {int, std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::cxx11::basic_string<char, std::char_traits, std::allocator >}; unsigned int column_count = 3u; trim_policy = io::trim_chars<' ', '\011'>; quote_policy = io::double_quote_escape<',', '''>; overflow_policy = io::single_line_comment<'#'>; comment_policy = io::no_comment]' /opt/tools/csv/csv-to-bin.cpp:47:49: required from here /opt/tools/csv/./csv.hpp:999:86: error: 'on_underflow' is not a member of 'io::single_line_comment<'#'>' overflow_policy::on_underflow(x); ^ /opt/tools/csv/./csv.hpp: In instantiation of 'void io::detail::parse_unsigned_integer(const char, T&) [with overflow_policy = io::single_line_comment<'#'>; T = unsigned int]': /opt/tools/csv/./csv.hpp:983:65: required from 'void io::detail::parse(char, unsigned int&) [with overflow_policy = io::single_line_comment<'#'>]' /opt/tools/csv/./csv.hpp:1219:85: required from 'void io::CSVReader<column_count, trim_policy, quote_policy, overflow_policy, comment_policy>::parse_helper(std::size_t, T&, ColType& ...) [with T = unsigned int; ColType = {int, std::cxx11::basic_string<char, std::char_traits, std::allocator >}; unsigned int column_count = 3u; trim_policy = io::trim_chars<' ', '\011'>; quote_policy = io::double_quote_escape<',', '''>; overflow_policy = io::single_line_comment<'#'>; comment_policy = io::no_comment; std::size_t = long unsigned int]' /opt/tools/csv/./csv.hpp:1253:53: required from 'bool io::CSVReader<column_count, trim_policy, quote_policy, overflow_policy, comment_policy>::read_row(ColType& ...) [with ColType = {unsigned int, int, std::cxx11::basic_string<char, std::char_traits, std::allocator >}; unsigned int column_count = 3u; trim_policy = io::trim_chars<' ', '\011'>; quote_policy = io::double_quote_escape<',', '''>; overflow_policy = io::single_line_comment<'#'>; comment_policy = io::no_comment]' /opt/tools/csv/csv-to-bin.cpp:92:54: required from here /opt/tools/csv/./csv.hpp:968:77: error: 'on_overflow' is not a member of 'io::single_line_comment<'#'>' overflow_policy::on_overflow(x);

  • clang++-6.0

/opt/tool/csv/./csv.hpp:999:74: error: no member named 'on_underflow' in 'io::single_line_comment<'#'>' overflow_policy::on_underflow(x);


/opt/tools/csv/./csv.hpp:1018:26: note: in instantiation of function 
template specialization 
'io::detail::parse_signed_integer<io::single_line_comment<'#'>, int>' 
requested here
{parse_signed_integer<overflow_policy>(col, x);}
^
/opt/tools/csv/./csv.hpp:1219:63: note: in instantiation of function 
template specialization 
'io::detail::parse<io::single_line_comment<'#'> >' requested here
::io::detail::parse<overflow_policy>(row[r], t);
^
/opt/tools/csv/./csv.hpp:1253:41: note: in instantiation of function 
template specialization 'io::CSVReader<3, io::trim_chars<' ', '\t'>, 
io::double_quote_escape<',', '''>, io::single_line_comment<'#'>,
io::no_comment>::parse_helper<int, std::__cxx11::basic_string, 
std::__cxx11::basic_string >' requested here
parse_helper(0, cols...);
^
/opt/tools/csv/csv-to-bin.cpp:47:22: note: in instantiation of 
function template specialization 'io::CSVReader<3, io::trim_chars<' ', 
'\t'>, io::double_quote_escape<',', '''>, io::single_line_comment<'#'>,
io::no_comment>::read_row<int, std::__cxx11::basic_string, 
std::__cxx11::basic_string >' requested here

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub 
<https://github.com/ben-strasser/fast-cpp-csv-parser/issues/68>, or 
mute the thread 
<https://github.com/notifications/unsubscribe-auth/ALaAj9BHIhQmE5tC62a7xHC5uUvrlxJHks5uEGI2gaJpZM4VGQzB>.
awgn commented 6 years ago

Hi Ben, indeed you are right.

The problem was the order of the policies (I was passing the single_line_comment as the fourth argument where an overflow_policy was expected).

However, you should update the README.md, since in the example such a policy is passed in the wrong place as well.

Best, N.