Please replace if by if constexpr for C++ 17 and above
- Dominant language
- C++
- Stars
- 7.5k
- Forks
- 1.1k
- Avg merge
- 47m
- Merged PRs (30d)
- 1
Description
The following if statements should be if constexpr in C++17 and above:
https://github.com/google/draco/blob/b43b42c744f550f2a739c0ce7207e1fc078a7e3b/src/draco/attributes/geometry_attribute.h#L366
https://github.com/google/draco/blob/b43b42c744f550f2a739c0ce7207e1fc078a7e3b/src/draco/attributes/geometry_attribute.h#L369
https://github.com/google/draco/blob/b43b42c744f550f2a739c0ce7207e1fc078a7e3b/src/draco/attributes/geometry_attribute.h#L378
https://github.com/google/draco/blob/b43b42c744f550f2a739c0ce7207e1fc078a7e3b/src/draco/attributes/geometry_attribute.h#L381
https://github.com/google/draco/blob/b43b42c744f550f2a739c0ce7207e1fc078a7e3b/src/draco/attributes/geometry_attribute.h#L386
and not as trivial but constexpr parts from the following if statements should be extracted in separate if constexpr statements:
https://github.com/google/draco/blob/b43b42c744f550f2a739c0ce7207e1fc078a7e3b/src/draco/attributes/geometry_attribute.h#L407
https://github.com/google/draco/blob/b43b42c744f550f2a739c0ce7207e1fc078a7e3b/src/draco/attributes/geometry_attribute.h#L413
This way compiler warnings like
```
Warning C4804 '<': unsafe use of type 'bool' in operation
```
can be avoided in line https://github.com/google/draco/blob/b43b42c744f550f2a739c0ce7207e1fc078a7e3b/src/draco/attributes/geometry_attribute.h#L372
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 that in turn "calls"
ConvertComponentValue that causes the warning for ConvertComponentValue because language requirements.
Contributor guide
Assessment
This issue has not been assessed yet.