title: std::transform how to not return (and not throw), just skip?
body: <p>I want to display folder contents displaying (not having any folder system) So Having a <code>std::set&lt;string_file_names&gt;</code> with <code>std::strings</code> in it and some given path to some dir we want to search for folder contents as in normal fs. so having set of:</p>
  
  <pre><code>    set&lt;string&gt; demo_set;
  demo_set.insert("file1");
  demo_set.insert("file2");
  demo_set.insert("folder/file1");
  demo_set.insert("folder/file2");
  demo_set.insert("folder/folder/file1");
  demo_set.insert("folder/folder/file2");
  demo_set.insert("bin/obj/Debug/CloudServerPrototype/ra.write.1.tlog");
  demo_set.insert("bin/obj/Debug/CloudServerPrototype/rc.write.1.tlog");
  demo_set.insert("bin/obj/Debug/vc100.idb");
  demo_set.insert("bin/obj/Debug/vc100.pdb");
  </code></pre>
  
  <p>and search string <code>"bin/obj/Debug/"</code> we want to get 3 Items - folder, 2 files:</p>
  
  <pre><code>CloudServerPrototype/
  vc100.idb
  vc100.pdb
  </code></pre>
  
  <p>But we get also an empty line. How to not get it and how to throw an error in case of non items found?</p>
  
  <p>Entire code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;algorithm&gt;
  #include &lt;set&gt;
  #include &lt;string&gt;
  #include &lt;iterator&gt;
  
  using namespace std;
  
  struct get_pertinent_part
  {
      const std::string given_string;
  
      get_pertinent_part(const std::string&amp; s)
          :given_string(s)
      {
      }
  
      std::string operator()(const std::string&amp; s)
      {
          std::string::size_type first = 0;
  
          if (s.find(given_string) == 0)
          {
              first = given_string.length();
          }
          else
          {
              return "";
          }
  
          std::string::size_type count = std::string::npos;
          std::string::size_type pos = s.find_last_of("/");
          if (pos != std::string::npos &amp;&amp; pos &gt; first)
          {
              count = pos + 1 - first;
          }
  
          return s.substr(first, count);
      }
  };
  
  void directory_listning_without_directories_demo()
  {
      set&lt;string&gt; output;
      set&lt;string&gt; demo_set;
  
      demo_set.insert("file1");
      demo_set.insert("file2");
      demo_set.insert("folder/file1");
      demo_set.insert("folder/file2");
      demo_set.insert("folder/folder/file1");
      demo_set.insert("folder/folder/file2");
      demo_set.insert("bin/obj/Debug/CloudServerPrototype/ra.write.1.tlog");
      demo_set.insert("bin/obj/Debug/CloudServerPrototype/rc.write.1.tlog");
      demo_set.insert("bin/obj/Debug/vc100.idb");
      demo_set.insert("bin/obj/Debug/vc100.pdb");
  
  
      std::transform(demo_set.begin(),
          demo_set.end(),
          std::inserter(output, output.end()),
          get_pertinent_part("bin/obj/Debug/"));
  
      std::copy(output.begin(),
          output.end(),
          std::ostream_iterator&lt;std::string&gt;(std::cout, "\n"));
  }
  
  int main()
  {
      directory_listning_without_directories_demo();
      cin.get();
      return 0;
  }
  </code></pre>
  
  <p>code sample based on <a href="https://stackoverflow.com/questions/7169320/setstring-how-to-list-not-strings-starting-with-given-string-and-ending-with/7169544#7169544">this</a> grate answer.</p>