[odb-users] Containers of containers
Andrew Cunningham
odb at a-cunningham.com
Wed Aug 17 18:30:28 EDT 2016
HI Boris,
I just got bitten badly by a containers of containers issue. I had
unintentionally used an object with a std::array<float,3> member variable
in the "value" type of a std::map.
e.g.
#pragma db value
class XYZ
{
std::array<float,3> xyz_;
};
...
#pragma db object
class D
{
std::map<int,XYZ> mapxyz_; <---oops, container of container
}
I would like that the ODB compiler detect this issue and fail with an
error. At the moment, the compiler runs without error and generates
'working' ODB code.
The objects can be persisted without apparent error, but after opening the
database and loading the objects , one will find that the std::map is
loaded with value objects having a std::array full of 0.0 data.
On a related issue, I also would like the ODB compiler to be enhanced to
deal with fixed sized arrays of 'simple' data types (other than char) not
as containers - put them in the object as members/columns.
For example
float xyz_[3];
or
std::array<float,3> xyz_;
At the moment, this type of member data has to be spelled out as, say,
float x_;
float y_;
float z_;
if you ever intend the owning class to be used in a container.
Andrew
More information about the odb-users
mailing list