Tidy up YGFloatOptional further

Summary: I missed these two things: inline default ctor, getValue() should return a float.

Reviewed By: priteshrnandgaonkar

Differential Revision: D8826640

fbshipit-source-id: e6324dea0268ef276e6fa1722e72dffb5241e676
This commit is contained in:
Scott Wolchok 2018-07-13 12:34:49 -07:00 committed by Facebook Github Bot
parent e589595bc9
commit 727ee92de5
2 changed files with 3 additions and 5 deletions

View File

@ -20,9 +20,7 @@ YGFloatOptional::YGFloatOptional(float value) {
}
}
YGFloatOptional::YGFloatOptional() : value_(0), isUndefined_(true) {}
const float& YGFloatOptional::getValue() const {
float YGFloatOptional::getValue() const {
if (isUndefined_) {
// Abort, accessing a value of an undefined float optional
std::cerr << "Tried to get value of an undefined YGFloatOptional\n";

View File

@ -14,12 +14,12 @@ struct YGFloatOptional {
public:
explicit YGFloatOptional(float value);
explicit YGFloatOptional();
explicit YGFloatOptional() : value_(0), isUndefined_(true) {}
// Program will terminate if the value of an undefined is accessed. Please
// make sure to check if the optional is defined before calling this function.
// To check if float optional is defined, use `isUndefined()`.
const float& getValue() const;
float getValue() const;
// Sets the value of float optional, and thus isUndefined is assigned false.
void setValue(float val) {