[odb-users] tagging a base struct member as id

Boris Kolpackov boris at codesynthesis.com
Wed Jun 17 06:44:30 EDT 2015


Hi,

MM <finjulhich at gmail.com> writes:

> struct Base {
>   std::uint32_t  id;
>   virtual ~Base() =0;
> };
>
> struct Derived : public Base {
>    ...
> };
>
> #pragma db object(Derived) table("mytable") definition
> #pragma db member(Derived::id) id auto

I believe the problem is due to the id member being in Base,
which is transient. If having it transient is the intention,
then you can still achieve what you want using a virtual data
member:

#pragma db member(Derived::id) virtual(std::uint32_t) access(Base::id) id auto

Boris



More information about the odb-users mailing list