You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Intellisense not working properly when template class is defined in cpp file (0.26.0-insiders3) #4424
Intellisense failing to auto-complete in template class function definitions in cpp files when auto-complete target is included after template class declaration header file. This is hard-to describe, so let me illustrate instead;
Consider we have following header files
foo.hpp
#pragma once
// template class declaration, no definition provided
template<typename T>
struct foo{
void do_foo();
};
bar.hpp
#pragma once
struct bar{
void do_bar();
};
And I want to define foo class in cpp file, foo.cpp
foo.cpp
#include "foo.hpp"
#include "bar.hpp"
// foo template class definition
template<typename T>
void foo<T>::do_foo(){
bar x;
// here, intellisense fails to show do_bar() when x. is pressed
x.do_bar();
}
But when the order of the includes are changed, the problem disappears
foo.cpp (order change)
#include "bar.hpp" // include bar first
#include "foo.hpp"
// template definition
template<typename T>
void foo<T>::do_foo(){
bar x;
// works as expected, intellisense shows do_bar() in autocomplete box
x.do_bar();
}
Another interesting point is, this only happens when foo is a template class. When I declare foo as a regular class/struct, problem disappears. So my best guess is, intellisense somehow acts as if foo template class is being defined in a header file. In that scenario, this outcome would make sense. But, this shouldn't be the case when defining foo in cpp file.
Expected behavior
Intellisense should be able to auto-complete the declarations included after declaration of template class, when definition of template class is made in other file. The order of includes should not affect the autocomplete suggestions when described scenario is in effect.
Activity
Colengms commentedon Oct 14, 2019
Hi @mustafakemalgilor . Thanks for reporting this.
I'm able to repro in VS, with gcc IntelliSense Mode. (VS and the VS Code C/C++ extension share some common code for IntelliSense).
I've opened a bug against VS here for tracking: https://developercommunity.visualstudio.com/content/problem/776487/incorrect-intellisense-in-clang-or-gcc-mode-with-t.html
Colengms commentedon Oct 22, 2020
The linked bug in VS was fixed, but the issue still repro's with the C/C++ Extension, for some reason.
Colengms commentedon Dec 17, 2024
Not sure when this got fixed, but I'm unable to repro with 1.23.2. Closing as fixed.