[odb-users] How to persist a custom collection adapted from
std::vector ?
Boris Kolpackov
boris at codesynthesis.com
Tue Feb 4 06:33:29 EST 2020
ALAIN MARI <alain.mari at se.com> writes:
> template <typename T>
> class os_Array : private std::vector<T>
> {
> ...
> }
>
> What could be the best way to make my field persistent with my own
> wrapper class ?
You need to provide the odb::container_traits<os_Array> specialization
similar to how libodb provides one for std::vector (and other containers).
The comment at the beginning of this file has more information on how
to set everything up:
https://git.codesynthesis.com/cgit/odb/libodb/tree/odb/c-array-traits.hxx
(You could also provide this specialization in the same header as os_Array
if you don't want to mess with the ODB compiler options.)
See the std::vector specialization for an example:
https://git.codesynthesis.com/cgit/odb/libodb/tree/odb/std-vector-traits.hxx
More information about the odb-users
mailing list