[odb-users] Persisting class instantiated from a template
Boris Kolpackov
boris at codesynthesis.com
Thu Mar 16 12:37:37 EDT 2017
Hi Balázs,
Ok, I tried to actually compile your example with this contents of
the mapping file:
typedef Result<float, 7> ResultFloatSeven;
#pragma db value(ResultFloatSeven) definition transient
#pragma db member(ResultFloatSeven::Id_) virtual(int)
#pragma db member(ResultFloatSeven::Value_) virtual(float)
The error I get is this:
mapping.hpp:7:12: error: no suitable accessor function could be automatically found for virtual data member 'Value_'
mapping.hpp:7:12: info: use '#pragma db get' to explicitly specify the accessor function or expression
Which makes sense, after looking at what you have:
valuetype getValue(int i) const { return Values[i]; }
void setValue(valuetype _value, int i) { Values[i] = _value; }
These are not suitable accessors/modifiers (ODB cannot magically know
what to pass for i). You need something like this:
valuetype getValue() const;
void setValue(valuetype)
Boris
More information about the odb-users
mailing list