Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8217411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:27:35+00:00 2026-06-07T12:27:35+00:00

I searched to see if I find a solution to this problem but I

  • 0

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));         
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:27:37+00:00Added an answer on June 7, 2026 at 12:27 pm

    C++ is not a simple language to parse and semantic. Therefore you can’t expect IntelliSense to work perfectly with complicated types.

    As for your code, you could simplify the code to do:

    dataSets->clear();  // no need to use `get` here.
    
    for (auto& ignored : *argList) {  // use range-based for.
        auto ps = this->createPreparedStatment(sqlText,args);
        dataSets->insert(ps->execute());  // no need to define 'rs'.
        // no need to release explicitly, if they are indeed smart pointers.
    }
    

    (And if dataSets is really a unique_ptr<vector<unique_ptr<T>>> I think you should use dataSets->push_back instead of insert.)


    Edit: MSVC 2010 does not support range-based for. It does support lambdas though:

    std::for_each(argList->cbegin(), argList->cend(), [&](const vector<SQLDataType>&) {
       auto ps = this->createPreparedStatment(sqlText,args);
       dataSets->insert(ps->execute());  // no need to define 'rs'.
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Searched a lot about this problem but never found a answer, that solved it.
I've searched for two days trying to find a solution to this. My problem
I've searched for an answer and no solution seems to fix this problem, so
I've searched for this everywhere but I can't seem to find a solution; maybe
I have searched around a lot for a solution, but could not find any.
I've searched for a solution for my problem all over but I cannot find
I have searched this site extensively but cannot find a solution. Here is the
I've searched around for a solution to my problem but couldn't find one so
I searched before asking this question. I didn't find an answer probably because I
I've searched around for solutions to this problem, and the only answer I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.