google / google/draco

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

Open
#1,087 0 comments 0 reactions 0 assignees View on GitHub
enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.