[odb-users] unable to map C++ type '::std::chrono::duration< double >'

Monika Idzik moni.idzik at gmail.com
Thu Sep 12 19:45:11 EDT 2019


Hi Paul,
thank you for the answer.
I'm integrating odb into a bigger project that's why I want to use whatever
already is being used in a project (and try not to change it if I don't
have to).
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.

I need the precision of microseconds for this project.

I didn't include the header cause it's a bigger project, but basically it
would look something like this:
#include <chrono>

#pragma db object
class TestChonoClass
{
public:
...

private:
  friend class odb::access;

  #pragma db id auto
  unsigned long id_;

  const std::chrono::duration<double> test_chrono;
};

If there is no easy way to have std::chrono::duration in the database. I
will try with the boost library; just wanted to know if I need to change
the existing code to have this particular value in the database.


Firstly, do you really wish to store a std::chrono::duration attribute in
> your data object?
>
> The second question is what time precision do you need in your data object?
>


More information about the odb-users mailing list