title: Returning an empty vector of strings if key is not found
body: <p>I know it is a very bad idea, so other suggestions on how to do it efficiently will be well-received.</p>
  
  <p>Here's the thing. I have <code>map&lt;string,vector&lt;string&gt; &gt;</code> , I want to search for a key and return its corresponding value (vector of strings in this case). Reason I insist on returning (rather than just iterating) is I need to search the values returned in some other vector.</p>
  
  <p>An example will make this clear:</p>
  
  <pre><code>Input:
  
  key1 ---&gt; {2,3,4}
  key2 ---&gt; {1}
  key3 ---&gt; {2,12,11,9}
  </code></pre>
  
  <p>For key1 as input, vector with values 2,3,4 should be returned. Now these 2,3,4 values need to be searched in other vector of strings. What is the most efficient way to do this?</p>
  
  <p>I tried something like this:</p>
  
  <pre><code>vector&lt;string&gt; returnEdges(string key)
  {
      for (map&lt;string, vector&lt;string&gt; &gt;::iterator it=outgoing.begin();
      it!=outgoing.end();++it)
      {
          if (key.compare((*it).first)==0)
          {
              return (*it).second;
          }
      }
  
  
      //return string&lt;;//what should I return here????
  
  
  }
  </code></pre>
  
  <p>1) How should I return empty vector in case key is not found?</p>
  
  <p>2) what is the best way to implement this?</p>
  
  <p>I hope the question is clear.</p>
  
  <p>EDIT: As I wrote the question, I thought why not return an iterator? Do the people at SO give their approval for this idea?</p>