作为 STL 容器的类成员的完成失败。
作为 STL 容器的本地对象的完成工作正常。
例如,给定以下文件:
// 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 ----- */
我使用以下方法为这两个文件生成了标签:
ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q .
当我输入temp.
cpp 时,我得到了string
预期的成员函数列表。但是如果我输入str.
omnicppcomplete 会吐出“找不到模式”。
我注意到temp.
只有在我有using std::string;
声明的情况下才能完成。
如何完成对属于 STL 容器的班级成员的工作?
编辑
我发现如果我对标头进行以下修改,则对 STL 容器的成员的补全是有效的:
// foo.h
#include <string>
using std::string;
class foo {
public:
void set_str(const string &);
string get_str_reverse( void );
private:
string str;
};
基本上,如果我添加using std::string;
然后std::
从成员中删除名称空间限定符string str;
并重新生成标签文件,那么 OmniCppComplete 能够在str.
.
我是否let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
设置在.vimrc
.
问题在于将using
声明放在头文件中似乎是一个很大的禁忌,所以我又回到了原点。