Skip to content
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

Please replace if by if constexpr for C++ 17 and above #1087

Open
SergeyKorytnik opened this issue Nov 16, 2024 · 0 comments
Open

Please replace if by if constexpr for C++ 17 and above #1087

SergeyKorytnik opened this issue Nov 16, 2024 · 0 comments

Comments

@SergeyKorytnik
Copy link

The following if statements should be if constexpr in C++17 and above:

if (std::is_integral<OutT>::value) {

if (!std::is_same<T, bool>::value && std::is_integral<T>::value) {

if (std::is_floating_point<T>::value) {

if (sizeof(in_value) > sizeof(double)) {

} else if (sizeof(in_value) > sizeof(float)) {

and not as trivial but constexpr parts from the following if statements should be extracted in separate if constexpr statements:
if (std::is_integral<T>::value && std::is_floating_point<OutT>::value &&

} else if (std::is_floating_point<T>::value &&

This way compiler warnings like

Warning	C4804	'<': unsafe use of type 'bool' in operation	

can be avoided in line

if (in_value < kOutMin || in_value > std::numeric_limits<OutT>::max()) {

In template bool ConvertValue(AttributeValueIndex att_id, int8_t out_num_components, OutT *out_val) const
there is a long switch that "calls"/instantiates ConvertTypedValue<bool, OutT> that in turn "calls"
ConvertComponentValue<bool, OutT> that causes the warning for ConvertComponentValue<bool, float> because language requirements.

@SergeyKorytnik SergeyKorytnik changed the title Please replace if by if constexpr for C++ and above Please replace if by if constexpr for C++ 17 and above Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant