-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
enhancementSomething can be improvedSomething can be improvedfixedSomething works now, yay!Something works now, yay!good first issueGood for newcomersGood for newcomers
Description
The conditions of the if statements in duration_cast are all constant expressions, so we can change all of these occurences of plain if to if constexpr.
Lines 428 to 447 in ed8150e
| constexpr bool _Num_is_one = _CF::num == 1; | |
| constexpr bool _Den_is_one = _CF::den == 1; | |
| if (_Den_is_one) { | |
| if (_Num_is_one) { | |
| return static_cast<_To>(static_cast<_ToRep>(_Dur.count())); | |
| } else { | |
| return static_cast<_To>( | |
| static_cast<_ToRep>(static_cast<_CR>(_Dur.count()) * static_cast<_CR>(_CF::num))); | |
| } | |
| } else { | |
| if (_Num_is_one) { | |
| return static_cast<_To>( | |
| static_cast<_ToRep>(static_cast<_CR>(_Dur.count()) / static_cast<_CR>(_CF::den))); | |
| } else { | |
| return static_cast<_To>(static_cast<_ToRep>( | |
| static_cast<_CR>(_Dur.count()) * static_cast<_CR>(_CF::num) / static_cast<_CR>(_CF::den))); | |
| } | |
| } | |
| } |
Originally posted by @achabense in #3914 (comment)
This issue is intended for a new contributor (especially one new to GitHub) to get started with the simplest possible change.
Please feel free to submit a pull request if there isn't one already linked here - no need to ask for permission! 😸
You can (and should) link your pull request to this issue using GitHub's close/fix/resolve syntax.
Metadata
Metadata
Assignees
Labels
enhancementSomething can be improvedSomething can be improvedfixedSomething works now, yay!Something works now, yay!good first issueGood for newcomersGood for newcomers