[odb-users] Strange behavior of odb::details::transfer_ptr

Boris Kolpackov boris at codesynthesis.com
Tue May 2 10:10:42 EDT 2023


Reilly He <reillyhekazusa at gmail.com> writes:

> And in the constructor of odb::sqlite::database, *it takes a transfer_ptr
> via its copy constructor:*
> 
> > database::
> > database (const string& name,
> >           int flags,
> >           bool foreign_keys,
> >           const string& vfs,
> >           transfer_ptr<connection_factory> factory)

This is an implementation detail (in order to support both std::auto_ptr
and std::unique_ptr in the same codebase until we get rid of C++98 support).
In your code, if you are using C++11 or later you should just treat it as
if it were std::unique_ptr, per the documentation:

https://www.codesynthesis.com/products/odb/doc/manual.xhtml#18.2

For example:

  std::unique_ptr<odb::sqlite::connection_factory> f (
    new odb::sqlite::connection_pool_factory (20));

  std::unique_ptr<odb::database> db (
    new odb::sqlite::database (...., std::move (f)));



More information about the odb-users mailing list