Since the order of evaluation of the arguments at the call site is indeterminate, I need guarantees that filename.wstring() does not modify errno.
The C++ standard does not give you this guarantee.
In well-behaved standard library implementations, calling p.wstring() on a std::filesystem::path p will never touch errno.
However, technically, the C++ Standard does not guarantee errno is never touched by any standard library function, because library implementers are not explicitly forbidden from doing so.
In practice, on all major standard libraries (libstdc++, libc++, MSVC), this function is implemented without calling any C library I/O routines.
@BoP Thanks, I know. This would require additional lines of code that I want to avoid if they can be avoided easily.
– j6t
I am afraid it is the only way. **(Lines of source code != more code in executable.)**