0

Is there a way to make clang_complete complete templates like this one:

template <class T>
class X {
  int member_;
};

template <class U>
void foo() {
  X<U> x;
  x. //<-- autocomplete member_ (doesn’t work)
}

This doesn’t work because the compiler doesn’t know what U is. And of course there could be a specialization of X that has other members.

But it would be helpful and very productive to be able to:

  • fallback to the generic version of the template if the template argument isn’t yet deduced
  • (or) cumulate generic and all specializations of the template and display them all.

Can this be done?

bolov
  • 72,283
  • 15
  • 145
  • 224
  • You do understand that `clang_complete` doesn't do completion itself, right? I'm asking because your suggestions can't be implemented in the plugin, they need to be implemented in Clang, then `clang_complete` will be able to use these new features through `libclang` wrapper. – xaizek Jul 19 '14 at 21:24
  • @xaizek Yes. I don’t know the API, but I figured that it is possible to get through libclang the generic version of a template. – bolov Jul 20 '14 at 07:05
  • even if you traverse the AST and get the generic version of a template, how would you tell Clang to complete it? These are separated parts of the API, which do not affect each other and both are for querying data. I doubt that this is possible with current `libclang` API, but I might be wrong. – xaizek Jul 20 '14 at 10:20

0 Answers0