Merge pull request #1298 from Repiteo/int-to-variant-fix

Add missing int→Variant conversions
pull/1310/head
David Snopek 2023-11-15 09:07:48 -06:00 committed by GitHub
commit c4b7b08c91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -154,10 +154,18 @@ public:
Variant(int64_t v);
Variant(int32_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(uint32_t v) :
Variant(int16_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(int8_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(uint64_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(uint32_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(uint16_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(uint8_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(double v);
Variant(float v) :
Variant((double)v) {}
@ -209,8 +217,12 @@ public:
operator bool() const;
operator int64_t() const;
operator int32_t() const;
operator int16_t() const;
operator int8_t() const;
operator uint64_t() const;
operator uint32_t() const;
operator uint16_t() const;
operator uint8_t() const;
operator double() const;
operator float() const;
operator String() const;

View File

@ -268,6 +268,14 @@ Variant::operator int32_t() const {
return static_cast<int32_t>(operator int64_t());
}
Variant::operator int16_t() const {
return static_cast<int16_t>(operator int64_t());
}
Variant::operator int8_t() const {
return static_cast<int8_t>(operator int64_t());
}
Variant::operator uint64_t() const {
return static_cast<uint64_t>(operator int64_t());
}
@ -276,6 +284,14 @@ Variant::operator uint32_t() const {
return static_cast<uint32_t>(operator int64_t());
}
Variant::operator uint16_t() const {
return static_cast<uint16_t>(operator int64_t());
}
Variant::operator uint8_t() const {
return static_cast<uint8_t>(operator int64_t());
}
Variant::operator double() const {
double result;
to_type_constructor[FLOAT](&result, _native_ptr());