Ricardo Muñoz
2013-04-21 09:38:32 UTC
Hi, I've been trying to use boost::tuple with a boost::optional element and
I get a bad::cast exception. Attached to this mail you can find the
complete test case but here is small code snippet:
That works:
row_type get_last_row(soci::session& sql)
{
unsigned int id = 0;
std::string str1;
boost::optional<std::string> str2;
sql << "SELECT id, str1, str2 from example ORDER BY id DESC LIMIT 1",
soci::into(id), soci::into(str1), soci::into(str2);
return row_type(id, str1, str2);
}
That does not:
row_type get_last_row2(soci::session& sql)
{
row_type myrow;
try
{
sql << "SELECT id, str1, str2 from example ORDER BY id DESC LIMIT 1",
soci::into(myrow);
}
catch(const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
}
return myrow;
}
Probably i'm missing something, but I can't find it.
Thanks in advance.
I get a bad::cast exception. Attached to this mail you can find the
complete test case but here is small code snippet:
That works:
row_type get_last_row(soci::session& sql)
{
unsigned int id = 0;
std::string str1;
boost::optional<std::string> str2;
sql << "SELECT id, str1, str2 from example ORDER BY id DESC LIMIT 1",
soci::into(id), soci::into(str1), soci::into(str2);
return row_type(id, str1, str2);
}
That does not:
row_type get_last_row2(soci::session& sql)
{
row_type myrow;
try
{
sql << "SELECT id, str1, str2 from example ORDER BY id DESC LIMIT 1",
soci::into(myrow);
}
catch(const std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
}
return myrow;
}
Probably i'm missing something, but I can't find it.
Thanks in advance.