Note that there are some explanatory texts on larger screens.

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

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload