matt-42 / silicon

A high performance, middleware oriented C++14 http web framework please use matt-42/lithium instead
http://siliconframework.org
MIT License
1.73k stars 138 forks source link

Sql fails with iteration on list of records #71

Open lythesia opened 5 years ago

lythesia commented 5 years ago

c("select id from users")() | [] (int &uid) { std::cout << uid << std::endl; }; fails with

usr/include/silicon/middlewares/sqlite_connection.hh:115:9: error: no matching member function for call to 'row_to_sio'
        row_to_sio(o);
        ^~~~~~~~~~
test.cc:36:39: note: in instantiation of function template specialization 'sl::sqlite_statement::operator|<(lambda at test.cc:36:41)>' requested here
  c("select id from users")() | [] (int &uid)
                                      ^
/usr/include/silicon/middlewares/sqlite_connection.hh:37:10: note: candidate template ignored: could not match 'sio<type-parameter-0-0...>' against 'int'
    void row_to_sio(iod::sio<A...>& o)

seems like only sio objects work with |?

matt-42 commented 5 years ago

Which compiler do you use ? This should works. See this test here: https://github.com/matt-42/silicon/blob/master/tests/mysql.cc#L96

lythesia commented 5 years ago

clang version 8.0.0 (tags/RELEASE_800/final) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin

lythesia commented 5 years ago

mysql_connection works as expected, but sqlite_connection fails