Fixed is_nil(size_t) when checking out-of-range element:
the behaviour should math get_at, which returns first element in case the index is out of range.
This commit is contained in:
parent
fde928b073
commit
a7eda7cc8e
@ -615,7 +615,7 @@ public:
|
|||||||
static double nil_value() { return std::numeric_limits<double>::quiet_NaN(); }
|
static double nil_value() { return std::numeric_limits<double>::quiet_NaN(); }
|
||||||
// A scalar is nil, or all values of a vector are nil.
|
// A scalar is nil, or all values of a vector are nil.
|
||||||
bool is_nil() const override { for (auto v : this->values) if (! std::isnan(v)) return false; return true; }
|
bool is_nil() const override { for (auto v : this->values) if (! std::isnan(v)) return false; return true; }
|
||||||
bool is_nil(size_t idx) const override { return std::isnan(this->values[idx]); }
|
bool is_nil(size_t idx) const override { return std::isnan(this->values[idx < values.size() ? idx : 0]); }
|
||||||
|
|
||||||
std::string serialize() const override
|
std::string serialize() const override
|
||||||
{
|
{
|
||||||
@ -1092,7 +1092,7 @@ public:
|
|||||||
static FloatOrPercent nil_value() { return { std::numeric_limits<double>::quiet_NaN(), false }; }
|
static FloatOrPercent nil_value() { return { std::numeric_limits<double>::quiet_NaN(), false }; }
|
||||||
// A scalar is nil, or all values of a vector are nil.
|
// A scalar is nil, or all values of a vector are nil.
|
||||||
bool is_nil() const override { for (auto v : this->values) if (! std::isnan(v.value)) return false; return true; }
|
bool is_nil() const override { for (auto v : this->values) if (! std::isnan(v.value)) return false; return true; }
|
||||||
bool is_nil(size_t idx) const override { return std::isnan(this->values[idx].value); }
|
bool is_nil(size_t idx) const override { return std::isnan(this->values[idx < values.size() ? idx : 0].value); }
|
||||||
|
|
||||||
std::string serialize() const override
|
std::string serialize() const override
|
||||||
{
|
{
|
||||||
@ -1404,7 +1404,7 @@ public:
|
|||||||
static unsigned char nil_value() { return std::numeric_limits<unsigned char>::max(); }
|
static unsigned char nil_value() { return std::numeric_limits<unsigned char>::max(); }
|
||||||
// A scalar is nil, or all values of a vector are nil.
|
// A scalar is nil, or all values of a vector are nil.
|
||||||
bool is_nil() const override { for (auto v : this->values) if (v != nil_value()) return false; return true; }
|
bool is_nil() const override { for (auto v : this->values) if (v != nil_value()) return false; return true; }
|
||||||
bool is_nil(size_t idx) const override { return this->values[idx] == nil_value(); }
|
bool is_nil(size_t idx) const override { return this->values[idx < values.size() ? idx : 0] == nil_value(); }
|
||||||
|
|
||||||
bool& get_at(size_t i) {
|
bool& get_at(size_t i) {
|
||||||
assert(! this->values.empty());
|
assert(! this->values.empty());
|
||||||
|
Loading…
Reference in New Issue
Block a user