draco icon indicating copy to clipboard operation
draco copied to clipboard

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

Open SergeyKorytnik opened this issue 1 year ago • 0 comments

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 <typename OutT> 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 avatar Nov 16 '24 19:11 SergeyKorytnik