8000 IntelliSense fails to deduce types of CRTP-based expression templates. · Issue #6183 · microsoft/vscode-cpptools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
IntelliSense fails to deduce types of CRTP-based expression templates. #6183
Closed
Closed
< 9B16 a class="Box-sc-g0xbh4-0 hVVawZ prc-Link-Link-85e08" href="#top">IntelliSense fails to deduce types of CRTP-based expression templates.#6183
@PiliLatiesa

Description

@PiliLatiesa

Type: LanguageService

Describe the bug

  • OS and Version: Linux x86_64
  • VS Code Version: 1.49
  • C/C++ Extension Version: 1.0.1
  • Other extensions you installed (and if the issue persists after disabling them): None
  • Does this issue involve using SSH remote to run the extension on a remote machine?: No
  • A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).

(Also reported as DEVCOM-1192188)

The following piece of code causes IntelliSense to display red squiggles in the identified line, albeit it is perfectly valid C++. It seems that either the EDG compiler or IntelliSense has trouble in figuring out the type of u + v.

template <int dim, int rank, typename, typename>
class BinaryExpr;

template <typename T>
class BaseExpr {};

template <int dim, int rank, typename... TRest, template <int, int, typename...> typename T>
class BaseExpr<T<dim, rank, TRest...>>
{
public:
  template <typename... URest, template <int, int, typename...> typename U>
  BinaryExpr<dim, rank, T<dim, rank, TRest...>, U<dim, rank, URest...>>
  operator +(BaseExpr<U<dim, rank, URest...>> const &rhs) const noexcept
    { return {*this, rhs}; }
};

template <int d, int r, typename T, typename U>
class BinaryExpr : public BaseExpr<BinaryExpr<d, r, T, U>>
{
private:
  BaseExpr<T> const &lhs;
  BaseExpr<U> const &rhs;

public:
  BinaryExpr(BaseExpr<T> const &lhs_, BaseExpr<U> const &rhs_) noexcept :
    lhs(lhs_), rhs(rhs_) {}
};

template <int dim, int rank>
class Field : public BaseExpr<Field<dim, rank>> {};

template <typename T>
void grad(BaseExpr<T> const &) {}

int main()
{
Field<2, 2> u, v;

grad(u + v); // ERROR: no instance of overloaded function matches the specified type
}

Steps to reproduce

  1. Just copy and paste the code in a file. It is a IntelliSense-related problem, independent of c_cpp_properties.json.

Expected behavior

IntelliSense to deduce the type of u + v.

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServiceVisual StudioInherited from Visual StudiobugfixedCheck the Milestone for the release in which the fix is or will be available.parser

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0