Move equaltiy function from utils to an operator on YGFloatOptional
Summary: Move equaltiy function from utils to an operator on YGFloatOptional Reviewed By: emilsjolander Differential Revision: D7303460 fbshipit-source-id: 41ec0076ace621ec1a5bdbab00b72eea57780fff
This commit is contained in:
committed by
Facebook Github Bot
parent
d85e2ee9c3
commit
5730be093e
@@ -8,6 +8,7 @@
|
||||
#include "YGFloatOptional.h"
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include "Yoga.h"
|
||||
|
||||
YGFloatOptional::YGFloatOptional(const float& value)
|
||||
: value_(value), isUndefined_(false) {}
|
||||
@@ -30,3 +31,25 @@ void YGFloatOptional::setValue(const float& val) {
|
||||
bool YGFloatOptional::isUndefined() const {
|
||||
return isUndefined_;
|
||||
}
|
||||
|
||||
bool YGFloatOptional::operator==(const YGFloatOptional& op) const {
|
||||
if (isUndefined_ == op.isUndefined()) {
|
||||
return isUndefined_ ? true : value_ == op.getValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool YGFloatOptional::operator!=(const YGFloatOptional& op) const {
|
||||
return !(*this == op);
|
||||
}
|
||||
|
||||
bool YGFloatOptional::operator==(const float& val) const {
|
||||
if (YGFloatIsUndefined(val) == isUndefined_) {
|
||||
return isUndefined_ ? true : val == value_;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool YGFloatOptional::operator!=(const float& val) const {
|
||||
return !(*this == val);
|
||||
}
|
||||
|
Reference in New Issue
Block a user