[odb-users] Inverse and composite Id

Sean Clarke sean.clarke at sec-consulting.co.uk
Thu Mar 2 17:28:52 EST 2017


Still investigating.... it definitely is something to do with the:

#pragma db value
    struct Id {
        int a;
        int b;
}

if I comment that out and add:

using Id = std::uint32_t;

and amend the operator< appropriately it seems to work.



Regards
Sean Clarke

On 1 March 2017 at 16:12, Boris Kolpackov <boris at codesynthesis.com> wrote:

> Hi Sean,
>
> Sean Clarke <sean.clarke at sec-consulting.co.uk> writes:
>
> > class A {
> >
> > #pragma db value
> >     struct Id {
> >         int a;
> >         int b;
> > }
> >
> > #pragma db id
> >     Id m_id;
> >
> > #pragma db value_not_null
> >     std::shared_ptr<B> m_b;
> >
> > };
> >
> >
> > class B {
> >     using id_t = std::uint32_t;
> >
> > #pragma db id
> >     id_t m_id;
> >
> > #pragma db inverse(m_b)
> >     std::vector<std::shared_ptr<A>> m_as;
> > };
> >
> > /<path>/odb_gen/A-odb.hxx:385:70: error: ‘image_type’ in ‘class
> > odb::access::composite_value_traits<B::Id, (odb::database_id)2u>’ does
> not
> > name a type
>
> The error suggests that you have it the other way around (Id is in B, not
> A, and A points to B). Assuming this is the case, my guess would be that
> the header that contains A doesn't include the one containing B. See
> Section 6.3, "Circular Relationships" in the manual for details on the
> issue and possible solutions.
>
> Boris
>


More information about the odb-users mailing list