-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Put else-return logic into tighter scope #5643
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
tm _Time; | ||
_Time.tm_sec = _Seconds; | ||
_Time.tm_min = _Minutes; | ||
_Time.tm_hour = _Hours; | ||
_Time.tm_mday = static_cast<int>(_Day); | ||
_Time.tm_mon = static_cast<int>(_Month) - 1; | ||
_Time.tm_year = _Year - 1900; | ||
_Time.tm_yday = _Yearday; | ||
_Time.tm_wday = _Weekday; | ||
return _Time; |
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.
I wonder whether it would be better to use designated list-initialization (i.e. return {.tm_sec = _Seconds, /*...*/};
) here.
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.
Which standard mode is this part and which standard ode is this syntax?
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.
Which standard mode is this part and which standard ode is this syntax?
Both are C++20.
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.
Yes, _Fill_tm
is defined in a #if _HAS_CXX20
scope (from line 2885); looks good.
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.
I always forget that that's a feature, but I have no objections to its use (unlike abbreviated function templates). In a followup PR, if you want to do this.
Thanks! 😻 The |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for simplifying things and avoiding dead code! ❌ 🧟 🎉 |
if-constexpr-return
into else scope if possible #5605. (Fixed_Hash_equal
,_Fill_tm
and_Validate_specifiers
; the remaining ones involve nestedif constexpr
and are untouched.)noexcept
enhancement.