I have a helper class for freeing MYSQL_RES handles.
class auto_mysqlres
{
public:
auto_mysqlres(MYSQL_RES *res) : m_res(res)
{
}
~auto_mysqlres()
{
if (m_res != NULL)
mysql_free_result(m_res);
}
operator MYSQL_RES* ()
{
return m_res;
}
private:
auto_mysqlres& operator= (const auto_mysqlres &res);
auto_mysqlres (const auto_mysqlres &res);
private:
MYSQL_RES *m_res;
};
when I try to use it this way
auto_mysqlres result = return_pointer_to_mysql_res();
I get the error in GCC 4.6.3: auto_mysqlres::auto_mysqlres(const auto_mysqlres&) is private
. no errors in MSVC 2008, though.
return_pointer_to_mysql_res
returns MYSQL_RES*
, of course
I have fixed the problem with this line auto_mysqlres result (return_pointer_to_mysql_res());
but I want to find out why I get that error. I can't understand why GCC creates a temporary object there.