User forums > Using Code::Blocks

Code completion and smart pointer

(1/3) > >>

Denis:
Code completion shows only fields of smart pointer, not of managed object. For example for code:

--- Code: --- std::auto_ptr<std::string> a;
a->

--- End code ---
I see only auto_ptr, element_type, get etc fields.

thomas:
Hmm well... how is code completion supposed to know? std::auto_ptr changes the meaning of operator->, and maps it to some class given as template parameter.

This is a tough challenge for code completion to figure out, as it can't guess by mere divination that operator-> in this particular template is meant to map to the template parameter, there would have to be a special code path that identifies std::auto_ptr specifically (and boost::scoped_ptr, boost::shared_ptr, and all the 350 other smart pointer implementations).

Denis:
But there are source code editors which can recognize reloaded operator-> and show correct code completion (borland c++ builder for example). I thing it is possible to make C::B code completion more smarter.

aurisc4:

--- Quote ---But there are source code editors which can recognize reloaded operator-> and show correct code completion (borland c++ builder for example). I thing it is possible to make C::B code completion more smarter.
--- End quote ---
Borland C++ Builder (at least version 6), seems to compile the code during code completion, that why it doesn't work, if there are syntax errors before the position, where cc is invoked. Also, this makes cc extremely slow on large projects.

thomas:

--- Quote from: Denis on September 29, 2007, 07:09:13 pm ---But there are source code editors which can recognize reloaded operator-> and show correct code completion (borland c++ builder for example). I thing it is possible to make C::B code completion more smarter.
--- End quote ---
Code completion has a lot more issues than just that. Feel free to contribute a better code completion engine.
Seriously, the development team would forever be in your debt.

As pointed out by aurisc4, the Borland C++ Builder solution (as the Microsoft one, too) uses the compiler for such tasks, and clearly, this is superior. However, the downside is that those programs only work with exactly one revision of one specific compiler (their own).
We don't have the luxury of being able to load gcc (or whatever compiler the user configures) as a DLL either, nor are there any provisions (to my knowledge) to offer the parse tree to another application.
At the very best, gcc can be asked to run a file through the preprocessor (substituting #include and #define, and evaluating #if), but again, this is a feature of one particular compiler, there's no guarantee that another compiler will work the same.

Navigation

[0] Message Index

[#] Next page

Go to full version