[odb-users] Pointer error with query_one but not with query_value

Javier Gutierrez javier.gutierrez at web.de
Fri Oct 18 05:31:39 EDT 2019


Hi there,



I modified a bit the example "view" to prove my error.

So I generate the API for the view employee_count (employee.hxx) with the
flag --default-pointer std::shared_ptr



Then in driver.cxx:



If I use following

      int count = db->query_value<employee_count>
(query<employee_count>::last == "Doe").count;

it gets compiled successfully:



If I use following

      int count = db->query_one<employee_count> (query<employee_count>::last
== "Doe")->count;

I get the error:

error: cannot convert 'odb::view_traits<employee_count>::pointer_type {aka
std::shared_ptr<employee_count>}' to 'pointer_type {aka employee_count*}' in
initialization



So I changed my code to use query_value instead.

But out of curiosity any idea what is wrong with the code using query_one?



Regards,

Javier



More information about the odb-users mailing list