[odb-users] Specializing wrapper_traits
Boris Kolpackov
boris at codesynthesis.com
Wed Apr 27 04:26:54 EDT 2016
Hi Steve,
Hales, Steve <Steve.Hales at garmin.com> writes:
> My team has a template class similar to odb::nullable that we would like to
> use to wrap nullable fields. I discovered the wrapper_traits class in
> ODB. It looks like we might be able to provide another specialization of
> wrapper_traits for our template class. Is that correct?
Yes, that's what it's for.
> If so, are there any examples available to provide guidance on how
> to achieve this?
The ODB Boost profile library (libodb-boost) has a specialization for
boost::optional. It shows how to do this "properly", i.e., it is completely
non-intrusive and can be enabled via the profile mechanism (pass
--profile|-p boost/optional). You can also do it like this, or you can add
the necessary prologue/epilogue options (see boost/optional.options) to the
ODB command line, or you can simply add the wrapper_traits specialization
into the same header as you nullable class template and then you won't need
to pass anything to the ODB compiler.
Boris
More information about the odb-users
mailing list