0

While attempting to pass a vector by const reference I'm receiving the following intellisense error (project builds successfully):

no instance of constructor "ObjOne::ObjOne" matches the argument list argument types are: (std::vector<int, std::allocator<int>>) 

enter image description here

I have commented in the below minimal reproducible example where the error occurs. Is there a known way to resolve issues such as these within visual studio 2017?

#include <vector> #include <string> #include <optional> class ObjOne { public: ObjOne(const std::vector<int>& p1) {} }; class ObjTwo { private: std::vector<int> testVec = { 1,2,3,4,5 }; std::optional<ObjOne> optObjOne; public: ObjTwo() {} void makeObjOne() { this->optObjOne = ObjOne(this->testVec); // Issue arises here } }; int main() { auto myObjTwo = ObjTwo(); myObjTwo.makeObjOne(); return 0; } 
9
  • Please reduce your problem to a minimal reproducible example. I cannot test what you are showing right now myself because the code is incomplete and I don't see any obvious issue (or I am overlooking it), maybe because there is too much irrelevant code. Commented Feb 16, 2020 at 18:24
  • 1
    There could be problems with the vertex.h or texture.h headers, so those should be added to the question. Also check and make sure you don't have multiple copies of those headers sitting around in different directories. Commented Feb 16, 2020 at 18:46
  • @walnut I have updated the question with a minimal reproducible example as requested. Apologies for not having done this from the start. Commented Feb 16, 2020 at 20:51
  • @whitwhoa I cannot reproduce the error with your code on either GCC, Clang or MSVC, see godbolt.org/z/P88oNz. What compiler and compiler options are you using? Commented Feb 16, 2020 at 20:57
  • @walnut I am using MSVC via visual studio 2017. The only options that are being used are /permissive- /GS which I believe was enabled by default and /std:c++ latest Commented Feb 16, 2020 at 21:07

1 Answer 1

1

Intellisense error when passing vector by const reference (but project builds)

I have tested your sample in my latest VS2017 and Intellisense works well as expected. So l wonder there are some problems with your VS environment and Intellisnese.

My environment-- OS: win10 1903 VS:VS2017 Community 19.9.20

You could try my suggestions to troubleshoot your issue:

As a suggestion, if your VS2017 is not the latest version, you could update it to the latest version which may have a newer fix.

1) close VS instance, delete the .vs hidden folder, bin folder and obj folder

2) clean the VS Component Cache under C:\Users\user\AppData\Local\Microsoft\VisualStudio\15.0_xxxxx\ComponentModelCache

3) open your project in VS and right-click on your project-->Properties-->C/C++-->Language-->set C++ Language Standard to ISO C++ 17 Standard(/std:c++17)

In addition, if these does not work ,please try to do a repair in VS Installer in case the Intellisense is broken.

Hope it could help you.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.