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

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Apr 2 06:49:05 PDT 2024


ldionne wrote:

I am seeing a bit of breakage of the exact form we'd expect:

```
error: no matching constructor for initialization of 'std::ifstream' (aka 'basic_ifstream<char>')
In file included from [...]:
[...]/usr/include/c++/v1/__fwd/fstream.h:24:28: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'std::string_view' (aka 'basic_string_view<char>') to 'const ifstream' for 1st argument
```

However, this breakage seems surmountable (a few projects broke but not *that* many). It'll be slightly annoying but not a deal breaker.

After reading the LWG issue, my understanding is that the intended usage is to instead construct a `std::string` explicitly when passing it to the `std::fstream` so as to explicitly call out that we're creating a null-terminated string. Is that correct?

Pinging @llvm/libcxx-vendors for awareness but this LGTM.

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


More information about the libcxx-commits mailing list