Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

soci into empty vector triggers error Vectors of size 0 are not allowed #1160

Open
yihuajack opened this issue Aug 11, 2024 · 0 comments
Open

Comments

@yihuajack
Copy link

According to the documentation https://soci.sourceforge.net/doc/master/binding/, I write

std::vector<int> ids;
sql << "SELECT ID FROM TABLE", soci::into(ids); 

It triggers soci_error("Vectors of size 0 are not allowed.") in src/backends/.../vector-into-type.cpp
However, if I write

std::vector<int> ids(1);

or initialize the capacity to any size larger than 0 the code can run. Is the error intentionally designed to throw if the size of the vector is 0? If so, why is it needed since into will automatically resize the vector?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant