Visual C++ 2013 and templated member function definitions

I am not sure if this forum is the right place to ask this, as - necessarily - the advice and help given here is compiler agnostic. However I am sure many of you chaps are using the MSVC IDE so may have encountered this problem yourself.

I have found that when writing the definitions for templated member functions of a templated class the VC++ IDE seems to partially stop working. Specifically it ceases to give auto-completion suggestions from the parent class's member function and data member list and also no longer highlights any errors the current line of text contains.

Admittedly these are completely necessary, purely ease-of-use functions, but it is surprizing how quickly you get used to them and I REALLY feel their lack!!!

Has anyone else encountered this or better yet solved it? I have not practiced with templates until very recently, so do not know if this is a long standing problem with the IDE.
I don't believe any autocomplete system that isn't a full-on compiler (e.g. Xcode interfaces with Clang to provide autocomplete and other functions) would work inside templates. Even then, there are things that will still not work because they depend on how the template was instantiated.
I did kind of wonder if it was an extension of the weirdness with having to define all your template functions inside the header file! I guess that is the issue then. Although the various auto-functions DO work if you write the member functions as inline inside the class declaration itself... Strange.

Its hard to look up any information on MSDN about this behaviour as how do you even describe it to the search engine?

An UPDATE:

A bit of experimentation seems to show the problem is Intellisense, if not the error-checker is not seeing the implicit 'this' pointer. If you deliberately prefix all the calls you make in templated members-functions to another templated member-function or data-member with 'this->' then you get the auto-completion selection back. It is probably terrible coding form however!!!
Last edited on
> Specifically it ceases to give auto-completion suggestions from the parent class's
> member function and data member list

>> If you deliberately prefix all the calls you make in templated members-functions
>> to another templated member-function or data-member with 'this->'
>> then you get the auto-completion selection back.

That is how I would want autocomplete to behave; it should look up names in precisely the same manner that the compiler would; it should conform to C++ parsing rules (two phase name lookup) for templates.

See: http://www.cplusplus.com/forum/general/69654/#msg371911
http://www.parashift.com/c++-faq-lite/nondependent-name-lookup-types.html
http://www.parashift.com/c++-faq-lite/nondependent-name-lookup-members.html
I can see what you are saying - and agree for the most part.

Even with 'this->' however the error-checker doesn't seem to work. But to be honest I find that more annoying that useful - whereas without autocomplete I feel like my fingers aren't working properly!!!

I guess my only question is - does using 'this->' have any performance implications? I would guess it doesn't as 'this' is implied anyway inside all member functions - its just as programmers we don't usually see it. I think...
Topic archived. No new replies allowed.