[odb-users] Containers of containers
Boris Kolpackov
boris at codesynthesis.com
Fri Jan 17 06:29:01 EST 2025
MM <finjulhich at gmail.com> writes:
> > My use case is a little extra on top of the vector<trip> case.
> > What is *trip* is not actually just a vector<country_stay> but somethine
> > like
> >
> > struct trip {
> > double d1;
> > int d2;
> > vector<country_stay> d3;
> > };
> >
> > how do I change that example code?
>
> Does the mechanism only work if the member type is
> std::vector<std::vector<T>>?
The second example in person.hxx seems to illustrate exactly what you
are trying to achieve:
// vector<struct{vector<value>}>
//
using phone_numbers = std::vector<std::string>;
#pragma db value
struct emergency_contact
{
std::string first_name;
std::string last_name;
#pragma db transient // Note: replaced with virtual below.
phone_numbers numbers;
};
using emergency_contacts = std::vector<emergency_contact>;
More information about the odb-users
mailing list