Intellisense is working very badly with my VS...
When I'm coding in C++ it works 100% fine, until I start using templates, then it just stops working completely, stops detecting errors and don't auto-complete in all cases.
I'm inclined to believe it has to do with something I have done with my code that broke it.
So I started by creating a class with a struct in it:
template<typename T>
class List<T>
{
private:
struct Node
{
T value;
Node* next;
Node* previous;
};
Node* First;
Node* Last;
...
};
later, I declare some additional functions:
template<typename T>
inline T List::First()
{
return First;
}
so far so good, intellisense is working 100% fine, but if I try to do first-> it won't work, VS won't tell give me any options (ctrl + space doesn't work).
also, if I type some nonsense it won't tell me it's wrong:
sdkjgisjdga->vsrsiib = 123jgi;
I don't really know what to do in order to fix this.
Thank you for your time and efforts.
PS: I already tried to reset the configurations.
EDIT: Forgot to say that if i don't use templates in my .h file then intellisense works correctly.
Troubleshooting. If you find IntelliSense has stopped working, the language service may not be running. Try restarting VS Code and this should solve the issue. If you are still missing IntelliSense features after installing a language extension, open an issue in the repository of the language extension.
You can enable or disable particular IntelliSense features in the Options dialog box, under Text Editor > C/C++ > Advanced. To configure IntelliSense for single files that aren't part of a project, look for the IntelliSense and browsing for non-project files section.
I would try: In Visual Studio 2015, go to 'Tools | Options | Text Editor | C# | General both "Auto list members" and "Parameter information" should be checked. If that doesn't work I would try to disable ReSharper in VS2013 and try to get the normal intellisense working.
Templates need to be instantiated before you can definitively say what they contain. For example, your First->
snippet points to a List<T>::Node
, and that is obviously dependent on the exact T
.
Sure, Intellisense in this simple case could unambiguously list the members by just substituting T==int
for a moment. But consider what's worse: Intellisense not knowing the members (like now) or Intellisense mis-guessing in the hard cases where you need it most?
I am a bit late with this answer, and maybe the OP is not working on this code anymore, but I think this may still help someone who is searching templates and IntelliSense.
One thing you can try -- if you want to be able to see your typos and errors as you type, but if you want your code to be template-able -- is using an #if-#else-#endif:
#if MY_USE_TEMPLATES
template <typename T>
#else
typedef [**your-test-type-here**] T;
#endif
class List {
... your code here ...
}
In Visual Studio 2015 this seems to work. You can define MY_USE_TEMPLATES to be 0 (using a #define), develop your code with IntelliSense and auto-complete, etc. (so you make less mistakes), and then change the MY_USE_TEMPLATES to 1 when you are ready to test or compile with actual template code.
While you have MY_USE_TEMPLATES turned on, code that references your List will result in error (i.e., code like 'List myList'), and you can resolve that with an extra dummy 'template' inside the #else statement. However, the good thing about leaving the #else clause without an extra 'template' is: the error you get when referencing your List may serve you as a reminder to turn on MY_USE_TEMPLATES before testing the code, reducing the probability of a bug. (Experience suggests that it is easy to forget when handling a lot of things and large projects ...)
Do be careful about using multiple such type definitions, however: the 'typedef ... T' can only be safely used once for that name "T"; while you can use 'typedef ... TYPE1' for one class and 'typedef ... TYPE2' for another, you cannot safely use the same type name for different types unless you put the different type names into separate namespaces. (I tried this in Visual Studio 2015.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With