
On 9/5/25 23:10, Christian Mazakas via Boost wrote:
On Fri, Sep 5, 2025 at 1:55 PM Maximilian Riemensberger via Boost < boost@lists.boost.org> wrote:
Approaching this from a different angle, I would naively expect the following two pieces of code to do the same thing (they don't):
// 1 void process_users(connection &conn) { statement st = conn.prepare("select * from users where name = ?"); resultset rs = st.execute({"allen"}); for (row const& r : rs) handle(r); }
//2 void process_users(connection &conn) { resultset rs = conn.prepare("select * from users where name = ?").execute({"allen"}); for (row const& r : rs) handle(r); }
I haven't been keeping up too much with this new library or review but how can these two snippets not do the exact same thing? What does each one do and why do they yield different results?
They yield the same results. They call different sqlite functions. The 1 snippet unnecessarily prepares the statement for rebinding and reexecution when rs gets destroyed. Not a big deal, admitted. But I didn't expect both snippets would do the exact same sqlite API calls. Any makes me feel a bit icky about the life-time management around statement. Best regards Max