Work around GCC5 compiling error in cuboid_rectangle.h (another approach to #42464) #44598
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: Build "Work around gcc 5 compiling error in cuboid_rectangle.h"
Purpose of change
In gcc 5, when
clamp
is called with explicit template argumentint
,clamp
incuboid_rectangle.h
conflicts withclamp
incata_utility.h
and a static_assert error is displayed. According to SFINAE,clamp
incuboid_rectangle.h
should be discarded, which is also the behavior of all other compilers. #42464 fixed it by casting arguments instead of using explicit template argument, but it made code more verbose just for the sake of a particularly old compiler.Describe the solution
Revert #42464 and work around the compiling error by checking for parent class / class member's existence in the template parameter list. Unfortunately this means that the classes in
cuboid_rectangle.h
cannot be foward declared.Describe alternatives you've considered
Dump gcc 5.3 support?
Testing
I used compiler explorer to test this change and it seemed to work with every major compiler. It still displays a
static_assert
message when it should, instead of displaying some obscure template error message.