[odb-users] Moving odb::result<T>
Sean Clarke
sean.clarke at sec-consulting.co.uk
Mon Sep 14 14:11:59 EDT 2015
> My guess would be you return the result out of transaction scope.
You are indeed correct!
Many thanks Boris, as helpful as ever.
Regards
Sean Clarke
---------------------------------------------
SEC Consulting Limited
Phone: +44 (0)23 8040 5599
Website: http://www.sec-consulting.co.uk
Email: sean.clarke at sec-consulting.co.uk
On 14 September 2015 at 18:55, Boris Kolpackov <boris at codesynthesis.com>
wrote:
> 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