Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete fails for templated class/struct #5039

Open
kbthomp1 opened this issue Mar 2, 2020 · 6 comments
Open

Autocomplete fails for templated class/struct #5039

kbthomp1 opened this issue Mar 2, 2020 · 6 comments
Labels
Feature: Auto-complete Language Service more votes needed Issues that have been postponed until more community members upvote it Visual Studio Inherited from Visual Studio
Milestone

Comments

@kbthomp1
Copy link

kbthomp1 commented Mar 2, 2020

Type: LanguageService

Describe the bug

  • OS and Version: MacOS Mojave 10.14.6
  • VS Code Version: 1.42.1
  • C/C++ Extension Version: 0.26.3
  • Other extensions you installed (and if the issue persists after disabling them):
  • A clear and concise description of what the bug is.

intelliSense autocomplete fails to deduce type of templated class declared in templated class/function.

To Reproduce

namespace ID {
template <typename T>
struct addingClass {
  public:
    addingClass(T a, T b) : result(a + b) {}
    const T result;
};

template <typename T>
class TemplatedClass {
  public:
    static T add(T a, T b) {
        auto addition = addingClass<T>(a, b);
        auto result = addition.result; // intelliSense provides not provide auto-complete for addingClass::result member
        return result;
    }
};
}

int main() {
    return ID::TemplatedClass<int>::add(-1, 1);
}

Hovering over the addition variable shows auto addition, and line 14 fails to auto-complete the result class member.

Expected behavior

I would expect auto-complete to deduce the class members of the addingClass in the above example.

Screenshots

Screen Shot 2020-03-02 at 3 08 36 PM

Screen Shot 2020-03-02 at 3 08 50 PM

Additional context

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "macFrameworkPath": [],
            "compilerPath": "/usr/local/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64",
            "configurationProvider": "vector-of-bool.cmake-tools"
        }
    ],
    "version": 4
}
@Colengms Colengms self-assigned this Mar 2, 2020
@Colengms
Copy link
Collaborator

Colengms commented Mar 2, 2020

Hi @kbthomp1 . I'm able to repro (a minimal version of) your issue in Visual Studio as well. (The C/C++ Extension shares code for IntelliSense with VS). I've opened a bug against VS here: https://developercommunity.visualstudio.com/content/problem/936260/intellisense-instance-of-template-stored-in-auto-d.html

@Colengms Colengms removed their assignment Mar 2, 2020
@Colengms Colengms added this to the Tracking milestone Mar 2, 2020
@sean-mcmanus sean-mcmanus added the more votes needed Issues that have been postponed until more community members upvote it label Aug 18, 2021
@glingy
Copy link

glingy commented Dec 9, 2021

What is the status of this now that the bug report for VS has been deemed low priority and closed?

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Dec 13, 2021

@glingy We're tracking potential priority changes via upvotes to this GitHub issue (thumbs up icon on the original post).

If you have a Microsoft account, you can also re-file the issue on the VS side -- but FYI they have a different system that requires they periodically close the lower priority issues after a certain period of time, so it could just be closed again later on.

@starball5
Copy link

Related question asked on Stack Overflow: Why doesn't Intellisense provide suggestions for templates inside templates that use parameters from the outer template?

@ShellScy
Copy link

@baskuit
Copy link

baskuit commented Jul 29, 2023

What if addingClass had a specialization that doesn't have the result member. How is the auto-complete supposed to know which specialization to use with only the totally generic T to go off of?

Anyway this seams to have been solved yeah? Atomic constraints on members will affect autocomplete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Auto-complete Language Service more votes needed Issues that have been postponed until more community members upvote it Visual Studio Inherited from Visual Studio
Projects
None yet
Development

No branches or pull requests

7 participants