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:
committed by
Facebook Github Bot
parent
0b1780a081
commit
2562c029b1
@@ -20,9 +20,7 @@ YGFloatOptional::YGFloatOptional(float value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YGFloatOptional::YGFloatOptional() : value_(0), isUndefined_(true) {}
|
float YGFloatOptional::getValue() const {
|
||||||
|
|
||||||
const float& YGFloatOptional::getValue() const {
|
|
||||||
if (isUndefined_) {
|
if (isUndefined_) {
|
||||||
// Abort, accessing a value of an undefined float optional
|
// Abort, accessing a value of an undefined float optional
|
||||||
std::cerr << "Tried to get value of an undefined YGFloatOptional\n";
|
std::cerr << "Tried to get value of an undefined YGFloatOptional\n";
|
||||||
|
@@ -14,12 +14,12 @@ struct YGFloatOptional {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit YGFloatOptional(float value);
|
explicit YGFloatOptional(float value);
|
||||||
explicit YGFloatOptional();
|
explicit YGFloatOptional() : value_(0), isUndefined_(true) {}
|
||||||
|
|
||||||
// Program will terminate if the value of an undefined is accessed. Please
|
// 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.
|
// make sure to check if the optional is defined before calling this function.
|
||||||
// To check if float optional is defined, use `isUndefined()`.
|
// 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.
|
// Sets the value of float optional, and thus isUndefined is assigned false.
|
||||||
void setValue(float val) {
|
void setValue(float val) {
|
||||||
|
Reference in New Issue
Block a user