[odb-users] unable to map C++ type '::std::chrono::duration<
double >'
Karen Arutyunov
karen at codesynthesis.com
Fri Sep 13 05:23:41 EDT 2019
> The variable type is std::chrono::duration, that's why I want to have it
> also in the database. I'm just asking if it's possible, not if it's the
> best way to represent the time duration/time point.
You can probably use the type mapping.
In our build2 toolchain project we use it for mapping timestamp (aka
std::chrono::system_clock::time_point) to uint64_t as a number of
nanoseconds from epoch:
#pragma db map type(timestamp) as(uint64_t) \
to(std::chrono::duration_cast<std::chrono::nanoseconds> ( \
(?).time_since_epoch ()).count ()) \
from(brep::timestamp ( \
std::chrono::duration_cast<brep::timestamp::duration> ( \
std::chrono::nanoseconds (?))))
For more details see
https://git.build2.org/cgit/brep/tree/libbrep/common.hxx#n107
More information about the odb-users
mailing list