rralf
rralf

Reputation: 1252

QT Creator and strange code completion using smart pointer

I'm using qtcreator (2.8.1) and there is some strange behaviour using smart pointer.

Have a look at this snippet:

class myclass {
public:
  void test() {};
};

....
std::shared_ptr<myclass> foo(new myclass);
foo->test();

std::unique_ptr<myclass> bar(new myclass);
bar->test();

If I type "foo->", the code completion window pops up, but if I type "bar->" nothing happens.

Any ideas why code completion only works with shared_ptrs and not with unique_ptrs?

UPDATE: It might be important to know that I'm using QT Creator with CMake and add_definitions(-std=c++11).

Upvotes: 4

Views: 1845

Answers (1)

hyde
hyde

Reputation: 62797

It's a bug.

At some point in future, Qt Creator may start to use a real compiler frontend (probably clang which is pretty good for this kind of use) to do it's C++ parsing for autocompletion and syntax highlighting, but 2.8.1 has it's own imperfect C++ parser. C++ with it's turing-complete templates and preprosessor macros and decades of accumulated legacy crud is insanely complex to parse (and, as a result, slow if you do it fully), so bugs like this aren't all too surprising if parsing isn't done by an actual standards-compliant compiler.

Upvotes: 5

Related Questions