Skip to content

Make constraint based auto-complete work with alias declarations. #11288

@baskuit

Description

@baskuit

Feature Request

Environment

OS and Version: Ubuntu 23.04
VS Code Version: 1.79.0
C/C++ Extension Version: 1.16.3

This should be the last of my issues. I'm putting the finishing touches on my code base and this is the last of the low hanging issues with how autocomplete and intellisense work with my concept system. Really great work so far, btw. I think the autocomplete should document my library nicely.

The following is a minimal example of what I mean

template <typename Type>
concept HasFoo = requires(Type &type) {
    type.foo();
};

struct T {
    void foo () {}
};

template <HasFoo Type>
struct Foo {
    using T = Type;
    Foo () {
        T x;
        Type y;
        // T will autocomplete `foo()`, x will NOT
    }
};

int main () {
    Foo<T> a{};
}

The name T cannot be associated to anything other than Type, which will have foo() suggested for it. However this suggestion does not appear after T x.

template <typename Types>
concept HasReal = requires(typename Types::Real &real) {
    real.reduce();
};

struct T {
    struct Real {
        void reduce () {}
    };
};

template <HasReal Types>
struct Foo {
    using R = typename Types::Real x;
    Foo () {
        R x;
        typename Types::Real y;
    }
};

int main () {
    Foo<T>();
}

This is another example of the auto complete not working as expected. It will work for typename Types::Real y but not R x.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions