[odb-users] mapping complex, templatized value types

Boris Kolpackov boris at codesynthesis.com
Sat Sep 19 09:55:06 EDT 2015


Hi Christian,

Christian Sell <christian at gsvitec.com> writes:

> template instances do not work, neither directly nor through 
> alias or typedef

Strange, this should work and appear to work for me:

$ cat test.hxx

#include <memory>
#include <utility>

using int_pair = std::pair<int, int>;
#pragma db value(int_pair) type("TEXT")

using shared_short_pair = std::shared_ptr<std::pair<short, short>>;
#pragma db value(shared_short_pair) type("TEXT")

#pragma db object
struct object
{
  #pragma db id
  int id;

  int_pair ip;
  std::pair<int, int> ip1;

  std::shared_ptr<int_pair> sip; // Ok, shared_ptr is a wrapper (Section 7.3).

  shared_short_pair ssp;
  std::shared_ptr<std::pair<short, short>> ssp1;
};

$ odb -d sqlite -s --std c++11 test.hxx

Can you try to adjust this example to reproduce your problem?

Boris



More information about the odb-users mailing list