Skip to content

Range for loop for statements#545

Open
Alvov1 wants to merge 5 commits into
SRombauts:masterfrom
Alvov1:181-feature-statement-iterator
Open

Range for loop for statements#545
Alvov1 wants to merge 5 commits into
SRombauts:masterfrom
Alvov1:181-feature-statement-iterator

Conversation

@Alvov1
Copy link
Copy Markdown

@Alvov1 Alvov1 commented Jun 1, 2026

Closes #181

Adds a nested RowIterator class to Statement that enables range-based for loops over query results:

SQLite::Statement query(db, "SELECT id, name FROM test");
for (SQLite::Statement& row : query)
{
    std::cout << row.getColumn(0).getInt() << "\n";
}

Notes:

  • begin() calls reset() automatically, so re-iterating the same Statement always starts from the beginning
  • Bindings set before the loop are preserved across reset()
  • Empty result sets are handled correctly (loop body never executes)
  • RowIterator satisfies std::input_iterator_tag with full iterator traits

@Alvov1 Alvov1 force-pushed the 181-feature-statement-iterator branch from fbb99e8 to 83bb827 Compare June 2, 2026 06:32
@SRombauts SRombauts self-assigned this Jun 2, 2026
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

Successfully merging this pull request may close these issues.

Implement iterators and range-based for loops

2 participants