Inline YGFloatOptional
completely
Summary: @public `YGFLoatOptional` only contains trivial functionality. Make it header-only. Reviewed By: SidharthGuglani Differential Revision: D13439609 fbshipit-source-id: 3f3c6c3a15e05ac55da2af30eb629f786ecb90a9
This commit is contained in:
committed by
Facebook Github Bot
parent
236bcc1a39
commit
96d93f2982
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#include "YGFloatOptional.h"
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include "Yoga-internal.h"
|
||||
#include "Yoga.h"
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
bool YGFloatOptional::operator==(YGFloatOptional op) const {
|
||||
return value_ == op.value_ || (isUndefined() && op.isUndefined());
|
||||
}
|
||||
|
||||
bool YGFloatOptional::operator!=(YGFloatOptional op) const {
|
||||
return !(*this == op);
|
||||
}
|
||||
|
||||
bool YGFloatOptional::operator==(float val) const {
|
||||
return value_ == val || (isUndefined() && yoga::isUndefined(val));
|
||||
}
|
||||
|
||||
bool YGFloatOptional::operator!=(float val) const {
|
||||
return !(*this == val);
|
||||
}
|
||||
|
||||
YGFloatOptional YGFloatOptional::operator+(YGFloatOptional op) const {
|
||||
return YGFloatOptional{value_ + op.value_};
|
||||
}
|
||||
|
||||
bool YGFloatOptional::operator>(YGFloatOptional op) const {
|
||||
return value_ > op.value_;
|
||||
}
|
||||
|
||||
bool YGFloatOptional::operator<(YGFloatOptional op) const {
|
||||
return value_ < op.value_;
|
||||
}
|
||||
|
||||
bool YGFloatOptional::operator>=(YGFloatOptional op) const {
|
||||
return *this > op || *this == op;
|
||||
}
|
||||
|
||||
bool YGFloatOptional::operator<=(YGFloatOptional op) const {
|
||||
return *this < op || *this == op;
|
||||
}
|
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
struct YGFloatOptional {
|
||||
private:
|
||||
@@ -18,7 +19,7 @@ struct YGFloatOptional {
|
||||
constexpr YGFloatOptional() = default;
|
||||
|
||||
// returns the wrapped value, or a value x with YGIsUndefined(x) == true
|
||||
float unwrap() const {
|
||||
constexpr float unwrap() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
@@ -26,14 +27,32 @@ struct YGFloatOptional {
|
||||
return std::isnan(value_);
|
||||
}
|
||||
|
||||
YGFloatOptional operator+(YGFloatOptional op) const;
|
||||
bool operator>(YGFloatOptional op) const;
|
||||
bool operator<(YGFloatOptional op) const;
|
||||
bool operator>=(YGFloatOptional op) const;
|
||||
bool operator<=(YGFloatOptional op) const;
|
||||
bool operator==(YGFloatOptional op) const;
|
||||
bool operator!=(YGFloatOptional op) const;
|
||||
YGFloatOptional operator+(YGFloatOptional op) const {
|
||||
return YGFloatOptional{value_ + op.value_};
|
||||
}
|
||||
bool operator>(YGFloatOptional op) const {
|
||||
return value_ > op.value_;
|
||||
}
|
||||
bool operator<(YGFloatOptional op) const {
|
||||
return value_ < op.value_;
|
||||
}
|
||||
bool operator>=(YGFloatOptional op) const {
|
||||
return *this > op || *this == op;
|
||||
}
|
||||
bool operator<=(YGFloatOptional op) const {
|
||||
return *this < op || *this == op;
|
||||
}
|
||||
bool operator==(YGFloatOptional op) const {
|
||||
return value_ == op.value_ || (isUndefined() && op.isUndefined());
|
||||
}
|
||||
bool operator!=(YGFloatOptional op) const {
|
||||
return !(*this == op);
|
||||
}
|
||||
|
||||
bool operator==(float val) const;
|
||||
bool operator!=(float val) const;
|
||||
bool operator==(float val) const {
|
||||
return value_ == val || (isUndefined() && yoga::isUndefined(val));
|
||||
}
|
||||
bool operator!=(float val) const {
|
||||
return !(*this == val);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user