mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-15 11:52:08 +07:00
return an empty type for empty uvalues
This commit is contained in:
@@ -2844,7 +2844,7 @@ namespace meta_hpp
|
||||
void reset();
|
||||
void swap(uvalue& other) noexcept;
|
||||
|
||||
[[nodiscard]] const any_type& get_type() const noexcept;
|
||||
[[nodiscard]] any_type get_type() const noexcept;
|
||||
|
||||
[[nodiscard]] void* get_data() noexcept;
|
||||
[[nodiscard]] const void* get_data() const noexcept;
|
||||
@@ -8698,10 +8698,9 @@ namespace meta_hpp
|
||||
vtable_t::do_swap(*this, other);
|
||||
}
|
||||
|
||||
inline const any_type& uvalue::get_type() const noexcept {
|
||||
static any_type void_type = resolve_type<void>();
|
||||
inline any_type uvalue::get_type() const noexcept {
|
||||
auto&& [tag, vtable] = vtable_t::unpack_vtag(*this);
|
||||
return tag == storage_e::nothing ? void_type : vtable->type;
|
||||
return tag == storage_e::nothing ? any_type{} : vtable->type;
|
||||
}
|
||||
|
||||
inline void* uvalue::get_data() noexcept {
|
||||
|
||||
@@ -178,7 +178,7 @@ TEST_CASE("meta/meta_utilities/value") {
|
||||
CHECK_THROWS(std::ignore = std::move(std::as_const(val)).get_as<int>());
|
||||
}
|
||||
|
||||
CHECK(meta::uvalue{}.get_type() == meta::resolve_type<void>());
|
||||
CHECK_FALSE(meta::uvalue{}.get_type());
|
||||
}
|
||||
|
||||
SUBCASE("ivec2&") {
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace meta_hpp
|
||||
void reset();
|
||||
void swap(uvalue& other) noexcept;
|
||||
|
||||
[[nodiscard]] const any_type& get_type() const noexcept;
|
||||
[[nodiscard]] any_type get_type() const noexcept;
|
||||
|
||||
[[nodiscard]] void* get_data() noexcept;
|
||||
[[nodiscard]] const void* get_data() const noexcept;
|
||||
|
||||
@@ -345,10 +345,9 @@ namespace meta_hpp
|
||||
vtable_t::do_swap(*this, other);
|
||||
}
|
||||
|
||||
inline const any_type& uvalue::get_type() const noexcept {
|
||||
static any_type void_type = resolve_type<void>();
|
||||
inline any_type uvalue::get_type() const noexcept {
|
||||
auto&& [tag, vtable] = vtable_t::unpack_vtag(*this);
|
||||
return tag == storage_e::nothing ? void_type : vtable->type;
|
||||
return tag == storage_e::nothing ? any_type{} : vtable->type;
|
||||
}
|
||||
|
||||
inline void* uvalue::get_data() noexcept {
|
||||
|
||||
Reference in New Issue
Block a user