[odb-users] Moving odb::result<T>
Boris Kolpackov
boris at codesynthesis.com
Mon Sep 14 13:55:33 EDT 2015
Hi Sean,
Sean Clarke <sean.clarke at sec-consulting.co.uk> writes:
> I just perform a simple query and return the resultant odb::result using a
> std::move....
odb::result is copyable, you can just return it by value without move().
Second paragraph from Section 4.4, "Query Result":
"It is best to view an instance of odb::result as a handle to a stream,
such as a socket stream. While we can make a copy of a result or assign
one result to another, the two instances will refer to the same result
stream. Advancing the current position in one instance will also advance
it in another. The result instance is only usable within the transaction
it was created in. Trying to manipulate the result after the transaction
has terminated leads to undefined behavior."
My guess would be you return the result out of transaction scope.
Boris
More information about the odb-users
mailing list