taocpp / taopq

C++ client library for PostgreSQL
Boost Software License 1.0
265 stars 40 forks source link

Vector doesn't seem to conform to has_reserve #36

Closed own2pwn closed 3 years ago

own2pwn commented 3 years ago

https://github.com/taocpp/taopq/blob/40d28760e32466c6ff2d94f1cb67b486e5a37d18/include/tao/pq/result.hpp#L151

using result_t = std::tuple<int, int>;
auto rows = resp.vector<result_t>();

resulting vector's size != it's capacity

d-frey commented 3 years ago

The standard only guarantees size <= capacity. What are the actual values you are seeing?

Also, I don't understand what this has to do with has_reserve. Could you be more specific?

own2pwn commented 3 years ago

Sorry for the delayed reply. I thought it is expected that has_reserve < vector <E> > would result in true so we fall in and allocate memory in advance. But in my case that's not true

d-frey commented 3 years ago

Ah, now I see. And you are right, has_reserve is broken and there is no unit test for it.