-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<fstream>: Implement LWG-3430
#1968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
miscco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats much better
barcharcraz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.