[libcxx-commits] [libcxx] [libc++] Implement LWG3430 avoid implicit conversion of the source arguments to `std::filesystem::path` when constructing `std::basic_*fstream` (PR #85079)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Mar 16 08:06:25 PDT 2024


https://github.com/mordante requested changes to this pull request.

This [LWG](https://cplusplus.github.io/LWG/issue3430) issue does not what the title says. Based on the issue
```
 This means the simpler, more obvious code is slower and uses more memory:

    string_view sv = "foo.txt";
    fstream f1(sv); // bad
    fstream f2(string(sv)); // good

We should just allow passing a string_view directly, since it already compiles but doesn't do what anybody expects or wants. 
```
The accepted resolution avoids the `path` to `string_view` conversion, but doesn't add the `string_view` constructor overload. Based on https://godbolt.org/z/TqoWTxT75 the change would disallow using a `string_view` instead of making its usage more efficient. I wonder whether this change in behaviour is intended, especially since the title suggests differently and the LWG-issue doesn't change Annex C. @jwakely is the change in behaviour intended?

@yronglin let's put this patch on hold for now. 


https://github.com/llvm/llvm-project/pull/85079


More information about the libcxx-commits mailing list