Put else-return logic into tighter scope#5643
Put else-return logic into tighter scope#5643StephanTLavavej merged 6 commits intomicrosoft:mainfrom
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.
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.
Which standard mode is this part and which standard ode is this syntax?
There was a problem hiding this comment.
Which standard mode is this part and which standard ode is this syntax?
Both are C++20.
There was a problem hiding this comment.
Yes, _Fill_tm is defined in a #if _HAS_CXX20 scope (from line 2885); looks good.
There was a problem hiding this comment.
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-returninto else scope if possible #5605. (Fixed_Hash_equal,_Fill_tmand_Validate_specifiers; the remaining ones involve nestedif constexprand are untouched.)noexceptenhancement.