FloatOptional GCC build fix and more constexpr (#1411)

Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1411

X-link: https://github.com/facebook/react-native/pull/39796

Pull Request resolved: https://github.com/facebook/yoga/pull/1414

GCC flags that `isUndefined()` is not declared `constexpr` but that `unwrapOrDefault()` is. `std::isnan` is not constexpr until C++ 23 (because we cannot have nice things), so I made `yoga::isUndefined()` constexpr, using the same code `std::isnan()` boils down to. I then made `FloatOptional` depend on `Comparison.h` (instead of the other way around), so we can use it.

Note that the use of the `std::floating_point` concept here requires the libc++ bump in the previous diff in the stack.

Reviewed By: yungsters

Differential Revision: D49896837

fbshipit-source-id: 61e2bbbfedecffd007a12d42d998e43d3cf5119c
This commit is contained in:
Nick Gerleman
2023-10-06 13:04:39 -07:00
committed by Facebook GitHub Bot
parent f700e1335c
commit 7fe6e345a7
4 changed files with 40 additions and 44 deletions

View File

@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
#include <cmath>
#include <gtest/gtest.h>
#include <yoga/YGValue.h>