Vim + OmniCppComplete: Completing on Class Members which are STL containers
- by Robert S. Barnes
Completion on class members which are STL containers is failing.
Completion on local objects which are STL containers works fine.
For example, given the following files:
// foo.h
#include <string>
class foo {
public:
void set_str(const std::string &);
std::string get_str_reverse( void );
private:
std::string str;
};
// foo.cpp
#include "foo.h"
using std::string;
string
foo::get_str_reverse ( void )
{
string temp;
temp.assign(str);
reverse(temp.begin(), temp.end());
return temp;
} /* ----- end of method foo::get_str ----- */
void
foo::set_str ( const string &s )
{
str.assign(s);
} /* ----- end of method foo::set_str ----- */
I've generated the tags for these two files using:
ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q .
When I type temp. in the cpp I get a list of string member functions as expected. But if I type str. omnicppcomplete spits out "Pattern Not Found".
I've noticed that the temp. completion only works if I have the using std::string; declaration.
How do I get completion to work on my class members which are STL containers?
Edit
I found that completion on members which are STL containers works if I make the follow modifications to the header:
// foo.h
#include <string>
using std::string;
class foo {
public:
void set_str(const string &);
string get_str_reverse( void );
private:
string str;
};
Basically, if I add using std::string; and then remove the std:: name space qualifier from the string str; member and regenerate the tags file then OmniCppComplete is able to do completion on str..
It doesn't seem to matter whether or not I have let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] set in the .vimrc.
The problem is that putting using declarations in header files seems like a big no-no, so I'm back to square one.