[odb-users] Possible bug or missing feature
Ronnie Chowdhury
ronnie.c995 at gmail.com
Mon Jun 19 09:42:00 EDT 2017
If using boost::posix_time (or boost::gregorian_date::date) in a std::vector<>, the generated code appears not to compile
Example:
#pragma db object
struct TSData
{
TSData() = default;
#pragma db id auto
uint32_t id = 0;
#pragma db type ("INTEGER")
std::vector<boost::posix_time::ptime> ts; // Fails
std::vector<float> m_close;
std::vector<float> m_open;
std::vector<float> m_high;
std::vector<float> m_low;
};
Error
H:\ Documents\CPP\include\odb/sqlite/traits.hxx(216): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
H:\Documents\CPP\include\odb/sqlite/traits.hxx(214): note: while compiling class template member function 'void odb::sqlite::default_value_traits<T,odb::sqlite::id_integer>::set_image(__int64 &,bool &,T)'
It appears to fail here
template <typename T, database_type_id ID>
struct default_value_traits
{
typedef T value_type;
typedef T query_type;
typedef typename image_traits<T, ID>::image_type image_type;
static void
set_value (T& v, const image_type& i, bool is_null)
{
if (!is_null)
v = T (i);
else
v = T ();
}
static void
set_image (image_type& i, bool& is_null, T v)
{
is_null = false;
i = image_type (v); // Fails here when using vector<posix_time::ptime>
}
};
This works
struct TSData
{
TSData() = default;
#pragma db id auto
uint32_t id = 0;
#pragma db type ("INTEGER")
boost::posix_time::ptime ts; // OK but this is not what I need
std::vector<float> m_close;
std::vector<float> m_open;
std::vector<float> m_high;
std::vector<float> m_low;
};
struct TSData
{
TSData() = default;
#pragma db id auto
uint32_t id = 0;
#pragma db type ("INTEGER")
std::vector<uin64_t> ts; // OK and a work around for now
std::vector<float> m_close;
std::vector<float> m_open;
std::vector<float> m_high;
std::vector<float> m_low;
};
What is the best way to address this?
Ronnie
More information about the odb-users
mailing list