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.
|
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.
The conditions of the if statements in
duration_castare all constant expressions, so we can change all of these occurences of plainiftoif constexpr.STL/stl/inc/__msvc_chrono.hpp
Lines 428 to 447 in ed8150e
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.