ccls icon indicating copy to clipboard operation
ccls copied to clipboard

"no matching function for call" caused by "candidate template ignored" when templated function is defined in header file

Open gdanov opened this issue 3 years ago • 0 comments

Observed behavior

Templated function calls are marked wrongly. Here is excerpt and example:

// utils.hpp
typedef std::function<String()> retfun;

template <typename T> retfun mk_tag(String name, T value) { 
   return [name, value]() { return name + "=" + String(value); };
}

here is the using file

// client.cpp

void setup(){
  mk_tag("abc", "def");
}

screenshot from VSCode configured to use ccls

Screenshot 2022-02-15 at 14 09 56

sorry for the extra context, if not obvious — this is arduino/platformio project.

Variant of the same code that works: removing the std::function return type:

// ccls does not complain when using this
template <typename T> String mk_tag(String name, T value) { 
   return name;
}

so, std::function somehow contributes to the problem. experimented with returning a vector<String>, same problem. Looks like any non-trivial return type triggers the problem.

Expected behavior

The code compiles, so I'd expect no complaints. Also, to the best of my knowledge this is valid code.

System information

  • ccls version
Homebrew ccls version 0.20210330-11-g790daca4
clang version 13.0.1

this is head, but with latest non-head behavior is the same

  • clang version:
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  • OS: OSX
  • Editor: emacs, vscode
  • Language client (and version): emacs-lsp latest elpa, latest vscode + ccls plug-in (v0.1.29)

gdanov avatar Feb 15 '22 13:02 gdanov