[odb-users] Iterate twice a result object

Aarón Bueno Villares abv150ci at gmail.com
Tue Jan 19 20:28:50 EST 2016

If I execute a query and get a result<T> object, can I make a double pass
of the "underlying" stream?

    auto result(db,query<person>());

    for (auto& o : result)
         // sth with o

    // later
    for (auto& o : result)
          // sth with o

A related question: when is the cached result of the query deleted? when
all copies of the result object are deleted (shared_ptr semantics)? or when
the first pass reaches to an end?

Best regards,

More information about the odb-users mailing list