I searched to see if I find a solution to this problem but I was not able to see an answer. The problem that I'm having is while my code compiles, I don't get intellisense
if I'm receiving a parameter (or declaring a variable) such as this with template T :
unique_ptr<vector<unique_ptr<T>>> & dataSets;
intellisense finds dataSets.get() but it does not find dataSets.get()->clear(); however, it compiles fine if I do it. However, if it not a template, it seems to work fine.
CODE:
template <typename T>
void mtsql::MTMySQL<T>::executePrepareStatement(const string & sqlText,const unique_ptr<vector<SQLDataType>> & argList,unique_ptr<vector<unique_ptr<T>>> & dataSets)
{
dataSets.get()->clear();
unique_ptr<sql::ResultSet> rs;
for (auto iter = argList->cbegin(); iter != argList->cend() ; ++iter)
{
auto ps = this->createPreparedStatment(sqlText,args);
rs.reset(ps->execute());
dataSets.get()->insert(std::move(rs));
ps.release();
}
}
I'm new at c++11 so I may be doing extra steps or steps that may be wrong (for example, I think ps.release() is not needed... my point was to delete it, but since is a smart point)
Thanks for the help!
EDIT 1: Thanks to the help, my code looks much nicer and without possible leakage. Thank you!
dataSets->clear();
for (auto iter = argList->cbegin(); iter != argList->cend() ; ++iter)
{
auto ps = this->createPreparedStatment(sqlText,args);
dataSets->push_back(std::move(rs));
}