Talk:cpp/filesystem/path/replace filename

The second part of the example seems to be UB as it has no filename? Should this be changed?

<< fs::path("/").replace_filename("bar") << '\n';

Best, Andreas 91.103.43.254 07:54, 14 September 2020 (PDT)


 * The example is ok. Here is an excerpt from the standard [n4860]:


 * UB is not mentioned at all. It seems that the statement
 * "The behavior is undefined if the path has no filename component"
 * should be removed from the page [replace_filename].


 * Ok, then the sentence should be removed and also the output on the page of the second example should be corrected from "bar" to "/bar". Correct?


 * Oh, yes. Thank you. Let's fix all that.