[odb-users] support for boost types
Boris Kolpackov
boris at codesynthesis.com
Mon May 7 04:22:52 EDT 2012
Hi Elizabeta,
elizabeta petreska <elizabeta.petreska at gmail.com> writes:
> Are the following boost types supported by odb, and if not ,will they be
> anytime soon ?
>
> 1) boost::multi-index
This container is not yet supported but should be easy to add. If you
are interested, I can implement something for you to try in the next
couple of days.
> 2) boost::scoped_ptr
scoped_ptr can be used right now to manage lifetime of objects that
have the raw pointer as their object pointer (the default). For
example:
boost::scoped_ptr<person> p (db.load<person> (id));
However, scoped_ptr cannot be used as an object pointer since it
is not copy-constructible or movable (i.e., we cannot return it
from a function, unlike, say, shared_ptr, unique_ptr, or auto_ptr).
Finally, boost::scoped_ptr can be used as a data member in a class,
for example:
class person
{
...
boost::scoped_ptr<std::string> middle_name_;
};
While this usage is not yet supported by ODB, it is trivial to add
(this is really an oversight mainly because this usage is not very
common).
Which use-case are you interested in?
> 3) boost::variant
This one is tricky since there is no portable, underlying SQL type to
map it to. See this recent thread for various ways of storing variant
in the database with ODB:
http://www.codesynthesis.com/pipermail/odb-users/2012-April/000494.html
> 4) boost::optional
This is supported. See Section 19.3, "Optional Library" in the ODB
manual:
http://www.codesynthesis.com/products/odb/doc/manual.xhtml#19.3
Boris
More information about the odb-users
mailing list