Inline YGFloatOptional
completely
Summary: @public `YGFLoatOptional` only contains trivial functionality. Make it header-only. Reviewed By: SidharthGuglani Differential Revision: D13209151 fbshipit-source-id: 3ecca015fa0ac6644ae694b44bc53d840fbc5635
This commit is contained in:
committed by
Facebook Github Bot
parent
64c37767c2
commit
59755d2874
@@ -1,57 +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-() const {
|
||||
return YGFloatOptional{-value_};
|
||||
}
|
||||
|
||||
YGFloatOptional YGFloatOptional::operator+(YGFloatOptional op) const {
|
||||
return YGFloatOptional{value_ + op.value_};
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
@@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include "Yoga-internal.h"
|
||||
|
||||
struct YGFloatOptional {
|
||||
private:
|
||||
@@ -17,7 +18,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_;
|
||||
}
|
||||
|
||||
@@ -35,16 +36,38 @@ struct YGFloatOptional {
|
||||
return isUndefined() ? f() : value_;
|
||||
}
|
||||
|
||||
YGFloatOptional operator-() const;
|
||||
YGFloatOptional operator+(YGFloatOptional op) const;
|
||||
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-() const {
|
||||
return YGFloatOptional{-value_};
|
||||
}
|
||||
YGFloatOptional operator+(YGFloatOptional op) const {
|
||||
return YGFloatOptional{value_ + op.value_};
|
||||
}
|
||||
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