[libcxx-commits] [PATCH] D91141: [9/N] [libcxx] Implement the stat function family on top of native windows APIs

Marek Kurdej via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 9 15:11:06 PST 2020

curdeius added inline comments.

Comment at: libcxx/src/filesystem/operations.cpp:409
+int set_errno(int e = GetLastError()) {
+  errno = static_cast<int>(__win_err_to_errc(e));
mstorsjo wrote:
> amccarth wrote:
> > Whoa!  I thought default argument values had to be compile-time constants.  I've never seen this done before.  Is this a newer C++ feature?
> No idea actually, I just tried it and it worked. If it wouldn't, it'd be trivial to make a parameterless overload of the function that just calls `set_errno(GetLastError())` anyway.
It's nothing new actually.
You must just be aware of the place where names used in the default argument are bound (declaration) and when they are evaluated (call) so to speak.
FYI, https://en.cppreference.com/w/cpp/language/default_arguments.



More information about the libcxx-commits mailing list