Before we look at how the new string type works, let's consider the following example of a function that is supposed to extract the name of a file without its extension. This is basically how you would write the function from the previous section before C++17.
std::string get_filename(std::string const & str) { auto const pos1 {str.find_last_of('')}; auto const pos2 {str.find_last_of('.')}; return str.substr(pos1 + 1, pos2 - pos1 - 1); } auto name1 = get_filename(R"(c:\test\example1.doc)"); // example1 auto name2 = get_filename(R"(c:\test\example2)"); // example2 if(get_filename(R"(c:\test\_sample_.tmp)").front() ...