Note that there are some explanatory texts on larger screens.

plurals
  1. POset<string>: how to list not strings starting with given string and ending with `/`?
    primarykey
    data
    text
    <p>for example we have in our set:</p> <pre><code> bin/obj/Debug/CloudServerPrototype/ra.write.1.tlog bin/obj/Debug/CloudServerPrototype/rc.write.1.tlog bin/obj/Debug/vc100.idb bin/obj/Debug/vc100.pdb </code></pre> <p>So this is what I tried based on this <a href="https://stackoverflow.com/questions/7169320/setstring-how-to-list-not-strings-starting-with-given-string-and-ending-with/7169544#7169544">grate answer</a>:</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() + 1; } 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>This outputs:</p> <pre><code>CloudServerPrototype/ file1 file2 folder/ folder/folder/ vc100.idb vc100.pdb </code></pre> <p>and we are given with <code>bin/obj/Debug/</code>string. We want to cout:</p> <pre><code>vc100.idb vc100.pdb CloudServerPrototype/ </code></pre> <p>How to do such thing?</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