<fstream>: Implement LWG-3430#1968
Conversation
LWG-3430 turns the constructors of `basic_{i,o,}fstream` that accept `filesystem::path` into templates that deduce the argument type and then constrain it to be `filesystem::path` to avoid potentially expensive implicit conversions. We already implement these constructors as templates for esoteric ABI-compatibility reasons (See https://github.com/microsoft/STL/blob/4c862ee11ce956556b810a813e77b0f8f97fb642/stl/inc/fstream#L20-L25) so the net change here is to make that template deduce the argument type and constrain it. I think we should also change our `experimental::filesystem::path` constructors in the spirit of LWG-3430, so I merged pairs of `experimental` / non-`experimental` constructors together using a new `_Is_any_path` trait to constrain
Existing test coverage in `tests\std\tests\VSO_0000000_path_stream_parameter` seems sufficient, so I've added no new tests.
<fstream>: Implement LWG-3430
barcharcraz
left a comment
There was a problem hiding this comment.
This could break user code right? Since with our current implementation we'd accept any type with a .c_str() overload.
Since the This will break user code that was constructing from a type that converts to |
StephanTLavavej
left a comment
There was a problem hiding this comment.
Looks good - I eventually realized that the other _Path_ish occurrences for open() can't be changed like this (as tempting as it would be).
|
Thanks for implementing this LWG issue resolution that also simplifies the code! 😺 📉 🎉 |
LWG-3430 turns the constructors of
basic_{i,o,}fstreamthat acceptfilesystem::pathinto templates that deduce the argument type and then constrain it to befilesystem::pathto avoid potentially expensive implicit conversions. We already implement these constructors as templates for esoteric ABI-compatibility reasons (SeeSTL/stl/inc/fstream
Lines 20 to 25 in 4c862ee
experimental::filesystem::pathconstructors in the spirit of LWG-3430, so I merged pairs ofexperimental/ non-experimentalconstructors together using a new_Is_any_pathtrait to constrain.Existing test coverage in
tests\std\tests\VSO_0000000_path_stream_parameterseems sufficient, so I've added no new tests.