mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-14 19:41:29 +07:00
return is_valid instead is_empty
This commit is contained in:
@@ -441,12 +441,12 @@ namespace meta_hpp::detail
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool is_empty() const noexcept {
|
[[nodiscard]] bool is_valid() const noexcept {
|
||||||
return vtable_ == nullptr;
|
return vtable_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] explicit operator bool() const noexcept {
|
[[nodiscard]] explicit operator bool() const noexcept {
|
||||||
return vtable_ != nullptr;
|
return is_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
R operator()(Args... args) const {
|
R operator()(Args... args) const {
|
||||||
@@ -1088,12 +1088,12 @@ namespace meta_hpp::detail
|
|||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool is_empty() const noexcept {
|
[[nodiscard]] bool is_valid() const noexcept {
|
||||||
return data_ == nullptr;
|
return data_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] explicit operator bool() const noexcept {
|
[[nodiscard]] explicit operator bool() const noexcept {
|
||||||
return data_ != nullptr;
|
return is_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() noexcept {
|
void reset() noexcept {
|
||||||
@@ -2235,12 +2235,12 @@ namespace meta_hpp
|
|||||||
type_base& operator=(type_base&&) noexcept = default;
|
type_base& operator=(type_base&&) noexcept = default;
|
||||||
type_base& operator=(const type_base&) = default;
|
type_base& operator=(const type_base&) = default;
|
||||||
|
|
||||||
[[nodiscard]] bool is_empty() const noexcept {
|
[[nodiscard]] bool is_valid() const noexcept {
|
||||||
return data_ == nullptr;
|
return data_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] explicit operator bool() const noexcept {
|
[[nodiscard]] explicit operator bool() const noexcept {
|
||||||
return data_ != nullptr;
|
return is_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] type_id get_id() const noexcept {
|
[[nodiscard]] type_id get_id() const noexcept {
|
||||||
@@ -2497,7 +2497,7 @@ namespace std
|
|||||||
template < meta_hpp::detail::type_family Type >
|
template < meta_hpp::detail::type_family Type >
|
||||||
struct hash<Type> {
|
struct hash<Type> {
|
||||||
size_t operator()(const Type& type) const noexcept {
|
size_t operator()(const Type& type) const noexcept {
|
||||||
return type.is_empty() ? 0 : type.get_id().get_hash();
|
return type.is_valid() ? type.get_id().get_hash() : 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -2506,15 +2506,15 @@ namespace meta_hpp
|
|||||||
{
|
{
|
||||||
template < detail::type_family L, detail::type_family R >
|
template < detail::type_family L, detail::type_family R >
|
||||||
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
||||||
return l.is_empty() == r.is_empty() && (l.is_empty() || l.get_id() == r.get_id());
|
return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_id() == r.get_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
template < detail::type_family L, detail::type_family R >
|
template < detail::type_family L, detail::type_family R >
|
||||||
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
||||||
if ( const std::strong_ordering cmp{!l.is_empty() <=> !r.is_empty()}; cmp != std::strong_ordering::equal ) {
|
if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) {
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
return l.is_empty() ? std::strong_ordering::equal : l.get_id() <=> r.get_id();
|
return l.is_valid() ? l.get_id() <=> r.get_id() : std::strong_ordering::equal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2522,12 +2522,12 @@ namespace meta_hpp
|
|||||||
{
|
{
|
||||||
template < detail::type_family L >
|
template < detail::type_family L >
|
||||||
[[nodiscard]] bool operator==(const L& l, type_id r) noexcept {
|
[[nodiscard]] bool operator==(const L& l, type_id r) noexcept {
|
||||||
return !l.is_empty() && l.get_id() == r;
|
return l.is_valid() && l.get_id() == r;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < detail::type_family L >
|
template < detail::type_family L >
|
||||||
[[nodiscard]] std::strong_ordering operator<=>(const L& l, type_id r) noexcept {
|
[[nodiscard]] std::strong_ordering operator<=>(const L& l, type_id r) noexcept {
|
||||||
return !l.is_empty() ? l.get_id() <=> r : std::strong_ordering::less;
|
return l.is_valid() ? l.get_id() <=> r : std::strong_ordering::less;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3366,12 +3366,12 @@ namespace meta_hpp
|
|||||||
state_base& operator=(state_base&&) noexcept = default;
|
state_base& operator=(state_base&&) noexcept = default;
|
||||||
state_base& operator=(const state_base&) = default;
|
state_base& operator=(const state_base&) = default;
|
||||||
|
|
||||||
[[nodiscard]] bool is_empty() const noexcept {
|
[[nodiscard]] bool is_valid() const noexcept {
|
||||||
return state_ == nullptr;
|
return state_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] explicit operator bool() const noexcept {
|
[[nodiscard]] explicit operator bool() const noexcept {
|
||||||
return state_ != nullptr;
|
return is_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const index_type& get_index() const noexcept {
|
[[nodiscard]] const index_type& get_index() const noexcept {
|
||||||
@@ -3632,7 +3632,7 @@ namespace std
|
|||||||
template < meta_hpp::detail::state_family State >
|
template < meta_hpp::detail::state_family State >
|
||||||
struct hash<State> {
|
struct hash<State> {
|
||||||
size_t operator()(const State& state) const noexcept {
|
size_t operator()(const State& state) const noexcept {
|
||||||
return state.is_empty() ? 0 : state.get_index().get_hash();
|
return state.is_valid() ? state.get_index().get_hash() : 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -3641,15 +3641,15 @@ namespace meta_hpp
|
|||||||
{
|
{
|
||||||
template < detail::state_family L, detail::state_family R >
|
template < detail::state_family L, detail::state_family R >
|
||||||
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
||||||
return l.is_empty() == r.is_empty() && (l.is_empty() || l.get_index() == r.get_index());
|
return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_index() == r.get_index());
|
||||||
}
|
}
|
||||||
|
|
||||||
template < detail::state_family L, detail::state_family R >
|
template < detail::state_family L, detail::state_family R >
|
||||||
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
||||||
if ( const std::strong_ordering cmp{!l.is_empty() <=> !r.is_empty()}; cmp != std::strong_ordering::equal ) {
|
if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) {
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
return l.is_empty() ? std::strong_ordering::equal : l.get_index() <=> r.get_index();
|
return l.is_valid() ? l.get_index() <=> r.get_index() : std::strong_ordering::equal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3657,12 +3657,12 @@ namespace meta_hpp
|
|||||||
{
|
{
|
||||||
template < detail::state_family L, detail::index_family R >
|
template < detail::state_family L, detail::index_family R >
|
||||||
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
||||||
return !l.is_empty() && l.get_index() == r;
|
return l.is_valid() && l.get_index() == r;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < detail::state_family L, detail::index_family R >
|
template < detail::state_family L, detail::index_family R >
|
||||||
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
||||||
return !l.is_empty() ? l.get_index() <=> r : std::strong_ordering::less;
|
return l.is_valid() ? l.get_index() <=> r : std::strong_ordering::less;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7873,7 +7873,7 @@ namespace meta_hpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool class_type::is_base_of(const class_type& derived) const noexcept {
|
inline bool class_type::is_base_of(const class_type& derived) const noexcept {
|
||||||
if ( is_empty() || derived.is_empty() ) {
|
if ( !is_valid() || !derived.is_valid() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7897,7 +7897,7 @@ namespace meta_hpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool class_type::is_derived_from(const class_type& base) const noexcept {
|
inline bool class_type::is_derived_from(const class_type& base) const noexcept {
|
||||||
if ( is_empty() || base.is_empty() ) {
|
if ( !is_valid() || !base.is_valid() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ namespace
|
|||||||
[[maybe_unused]]
|
[[maybe_unused]]
|
||||||
void meta_invoke_function_1(benchmark::State &state) {
|
void meta_invoke_function_1(benchmark::State &state) {
|
||||||
meta::function f = meta_bench_scope.get_function("static_function_1");
|
meta::function f = meta_bench_scope.get_function("static_function_1");
|
||||||
META_HPP_ASSERT(!f.is_empty());
|
META_HPP_ASSERT(f.is_valid());
|
||||||
|
|
||||||
for ( auto _ : state ) {
|
for ( auto _ : state ) {
|
||||||
f(static_angle);
|
f(static_angle);
|
||||||
@@ -138,7 +138,7 @@ namespace
|
|||||||
[[maybe_unused]]
|
[[maybe_unused]]
|
||||||
void meta_invoke_function_2(benchmark::State &state) {
|
void meta_invoke_function_2(benchmark::State &state) {
|
||||||
meta::function f = meta_bench_scope.get_function("static_function_2");
|
meta::function f = meta_bench_scope.get_function("static_function_2");
|
||||||
META_HPP_ASSERT(!f.is_empty());
|
META_HPP_ASSERT(f.is_valid());
|
||||||
|
|
||||||
for ( auto _ : state ) {
|
for ( auto _ : state ) {
|
||||||
f(static_angle, vmath::unit3_x<float>);
|
f(static_angle, vmath::unit3_x<float>);
|
||||||
@@ -148,7 +148,7 @@ namespace
|
|||||||
[[maybe_unused]]
|
[[maybe_unused]]
|
||||||
void meta_invoke_function_3(benchmark::State &state) {
|
void meta_invoke_function_3(benchmark::State &state) {
|
||||||
meta::function f = meta_bench_scope.get_function("static_function_3");
|
meta::function f = meta_bench_scope.get_function("static_function_3");
|
||||||
META_HPP_ASSERT(!f.is_empty());
|
META_HPP_ASSERT(f.is_valid());
|
||||||
|
|
||||||
for ( auto _ : state ) {
|
for ( auto _ : state ) {
|
||||||
f(static_angle, vmath::unit3_x<float>, 2.f);
|
f(static_angle, vmath::unit3_x<float>, 2.f);
|
||||||
@@ -158,7 +158,7 @@ namespace
|
|||||||
[[maybe_unused]]
|
[[maybe_unused]]
|
||||||
void meta_invoke_function_4(benchmark::State &state) {
|
void meta_invoke_function_4(benchmark::State &state) {
|
||||||
meta::function f = meta_bench_scope.get_function("static_function_4");
|
meta::function f = meta_bench_scope.get_function("static_function_4");
|
||||||
META_HPP_ASSERT(!f.is_empty());
|
META_HPP_ASSERT(f.is_valid());
|
||||||
|
|
||||||
for ( auto _ : state ) {
|
for ( auto _ : state ) {
|
||||||
f(static_angle, vmath::unit3_x<float>, 2.f, vmath::midentity3<float>);
|
f(static_angle, vmath::unit3_x<float>, 2.f, vmath::midentity3<float>);
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ TEST_CASE("meta/meta_base/fixed_function") {
|
|||||||
{
|
{
|
||||||
fixed_function<void()> ff;
|
fixed_function<void()> ff;
|
||||||
CHECK_FALSE(ff);
|
CHECK_FALSE(ff);
|
||||||
CHECK(ff.is_empty());
|
CHECK_FALSE(ff.is_valid());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
fixed_function<void()> ff = []{};
|
fixed_function<void()> ff = []{};
|
||||||
CHECK(ff);
|
CHECK(ff);
|
||||||
CHECK_FALSE(ff.is_empty());
|
CHECK(ff.is_valid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,11 +46,11 @@ TEST_CASE("meta/meta_base/fixed_function") {
|
|||||||
|
|
||||||
ff.reset();
|
ff.reset();
|
||||||
CHECK_FALSE(ff);
|
CHECK_FALSE(ff);
|
||||||
CHECK(ff.is_empty());
|
CHECK_FALSE(ff.is_valid());
|
||||||
|
|
||||||
ff = []{return 1;};
|
ff = []{return 1;};
|
||||||
CHECK(ff);
|
CHECK(ff);
|
||||||
CHECK_FALSE(ff.is_empty());
|
CHECK(ff.is_valid());
|
||||||
|
|
||||||
CHECK(ff() == 1);
|
CHECK(ff() == 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ TEST_CASE("meta/meta_base/memory_buffer") {
|
|||||||
memory_buffer buf;
|
memory_buffer buf;
|
||||||
|
|
||||||
CHECK(!buf);
|
CHECK(!buf);
|
||||||
CHECK(buf.is_empty());
|
CHECK_FALSE(buf.is_valid());
|
||||||
|
|
||||||
CHECK(buf.get_size() == 0);
|
CHECK(buf.get_size() == 0);
|
||||||
CHECK(buf.get_align() == std::align_val_t{});
|
CHECK(buf.get_align() == std::align_val_t{});
|
||||||
@@ -32,7 +32,7 @@ TEST_CASE("meta/meta_base/memory_buffer") {
|
|||||||
|
|
||||||
{
|
{
|
||||||
CHECK(!buf1);
|
CHECK(!buf1);
|
||||||
CHECK(buf1.is_empty());
|
CHECK_FALSE(buf1.is_valid());
|
||||||
|
|
||||||
CHECK(buf1.get_size() == 0);
|
CHECK(buf1.get_size() == 0);
|
||||||
CHECK(buf1.get_align() == std::align_val_t{});
|
CHECK(buf1.get_align() == std::align_val_t{});
|
||||||
@@ -43,7 +43,7 @@ TEST_CASE("meta/meta_base/memory_buffer") {
|
|||||||
|
|
||||||
{
|
{
|
||||||
CHECK(buf2);
|
CHECK(buf2);
|
||||||
CHECK(!buf2.is_empty());
|
CHECK(buf2.is_valid());
|
||||||
|
|
||||||
CHECK(buf2.get_size() == 10);
|
CHECK(buf2.get_size() == 10);
|
||||||
CHECK(buf2.get_align() == std::align_val_t{32});
|
CHECK(buf2.get_align() == std::align_val_t{32});
|
||||||
@@ -57,7 +57,7 @@ TEST_CASE("meta/meta_base/memory_buffer") {
|
|||||||
memory_buffer buf{10, std::align_val_t{32}};
|
memory_buffer buf{10, std::align_val_t{32}};
|
||||||
|
|
||||||
CHECK(buf);
|
CHECK(buf);
|
||||||
CHECK(!buf.is_empty());
|
CHECK(buf.is_valid());
|
||||||
|
|
||||||
CHECK(buf.get_size() == 10);
|
CHECK(buf.get_size() == 10);
|
||||||
CHECK(buf.get_align() == std::align_val_t{32});
|
CHECK(buf.get_align() == std::align_val_t{32});
|
||||||
@@ -82,7 +82,7 @@ TEST_CASE("meta/meta_base/memory_buffer") {
|
|||||||
|
|
||||||
{
|
{
|
||||||
CHECK(!buf1);
|
CHECK(!buf1);
|
||||||
CHECK(buf1.is_empty());
|
CHECK_FALSE(buf1.is_valid());
|
||||||
|
|
||||||
CHECK(buf1.get_size() == 0);
|
CHECK(buf1.get_size() == 0);
|
||||||
CHECK(buf1.get_align() == std::align_val_t{});
|
CHECK(buf1.get_align() == std::align_val_t{});
|
||||||
@@ -93,7 +93,7 @@ TEST_CASE("meta/meta_base/memory_buffer") {
|
|||||||
|
|
||||||
{
|
{
|
||||||
CHECK(buf2);
|
CHECK(buf2);
|
||||||
CHECK(!buf2.is_empty());
|
CHECK(buf2.is_valid());
|
||||||
|
|
||||||
CHECK(buf2.get_size() == 10);
|
CHECK(buf2.get_size() == 10);
|
||||||
CHECK(buf2.get_align() == std::align_val_t{32});
|
CHECK(buf2.get_align() == std::align_val_t{32});
|
||||||
@@ -112,7 +112,7 @@ TEST_CASE("meta/meta_base/memory_buffer") {
|
|||||||
|
|
||||||
{
|
{
|
||||||
CHECK(!buf1);
|
CHECK(!buf1);
|
||||||
CHECK(buf1.is_empty());
|
CHECK_FALSE(buf1.is_valid());
|
||||||
|
|
||||||
CHECK(buf1.get_size() == 0);
|
CHECK(buf1.get_size() == 0);
|
||||||
CHECK(buf1.get_align() == std::align_val_t{});
|
CHECK(buf1.get_align() == std::align_val_t{});
|
||||||
@@ -123,7 +123,7 @@ TEST_CASE("meta/meta_base/memory_buffer") {
|
|||||||
|
|
||||||
{
|
{
|
||||||
CHECK(buf2);
|
CHECK(buf2);
|
||||||
CHECK(!buf2.is_empty());
|
CHECK(buf2.is_valid());
|
||||||
|
|
||||||
CHECK(buf2.get_size() == 10);
|
CHECK(buf2.get_size() == 10);
|
||||||
CHECK(buf2.get_align() == std::align_val_t{32});
|
CHECK(buf2.get_align() == std::align_val_t{32});
|
||||||
@@ -138,7 +138,7 @@ TEST_CASE("meta/meta_base/memory_buffer") {
|
|||||||
buf.reset();
|
buf.reset();
|
||||||
|
|
||||||
CHECK(!buf);
|
CHECK(!buf);
|
||||||
CHECK(buf.is_empty());
|
CHECK_FALSE(buf.is_valid());
|
||||||
|
|
||||||
CHECK(buf.get_size() == 0);
|
CHECK(buf.get_size() == 0);
|
||||||
CHECK(buf.get_align() == std::align_val_t{});
|
CHECK(buf.get_align() == std::align_val_t{});
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ TEST_CASE("meta/meta_states/evalue") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::evalue evalue;
|
const meta::evalue evalue;
|
||||||
CHECK_FALSE(evalue);
|
CHECK_FALSE(evalue);
|
||||||
CHECK(evalue.is_empty());
|
CHECK_FALSE(evalue.is_valid());
|
||||||
CHECK(evalue == color_type.get_evalue("non-existent-evalue"));
|
CHECK(evalue == color_type.get_evalue("non-existent-evalue"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ TEST_CASE("meta/meta_states/function") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::function func;
|
const meta::function func;
|
||||||
CHECK_FALSE(func);
|
CHECK_FALSE(func);
|
||||||
CHECK(func.is_empty());
|
CHECK_FALSE(func.is_valid());
|
||||||
CHECK(func == ivec2_type.get_function("non-existent-function"));
|
CHECK(func == ivec2_type.get_function("non-existent-function"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ TEST_CASE("meta/meta_states/member") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::member member;
|
const meta::member member;
|
||||||
CHECK_FALSE(member);
|
CHECK_FALSE(member);
|
||||||
CHECK(member.is_empty());
|
CHECK_FALSE(member.is_valid());
|
||||||
CHECK(member == clazz_1_type.get_member("non-existent-member"));
|
CHECK(member == clazz_1_type.get_member("non-existent-member"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ TEST_CASE("meta/meta_states/method") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::method method;
|
const meta::method method;
|
||||||
CHECK_FALSE(method);
|
CHECK_FALSE(method);
|
||||||
CHECK(method.is_empty());
|
CHECK_FALSE(method.is_valid());
|
||||||
CHECK(method == ct.get_method("non-existent-method"));
|
CHECK(method == ct.get_method("non-existent-method"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ TEST_CASE("meta/meta_states/scope") {
|
|||||||
|
|
||||||
const meta::scope math_scope = meta::resolve_scope("meta/meta_states/scope/math");
|
const meta::scope math_scope = meta::resolve_scope("meta/meta_states/scope/math");
|
||||||
REQUIRE(math_scope);
|
REQUIRE(math_scope);
|
||||||
REQUIRE(!math_scope.is_empty());
|
REQUIRE(math_scope.is_valid());
|
||||||
|
|
||||||
CHECK(math_scope.get_name() == "meta/meta_states/scope/math");
|
CHECK(math_scope.get_name() == "meta/meta_states/scope/math");
|
||||||
CHECK(math_scope.get_variables().size() == 2);
|
CHECK(math_scope.get_variables().size() == 2);
|
||||||
@@ -66,7 +66,7 @@ TEST_CASE("meta/meta_states/scope") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::scope scope;
|
const meta::scope scope;
|
||||||
CHECK_FALSE(scope);
|
CHECK_FALSE(scope);
|
||||||
CHECK(scope.is_empty());
|
CHECK_FALSE(scope.is_valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("operators") {
|
SUBCASE("operators") {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ TEST_CASE("meta/meta_states/variable") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::variable variable;
|
const meta::variable variable;
|
||||||
CHECK_FALSE(variable);
|
CHECK_FALSE(variable);
|
||||||
CHECK(variable.is_empty());
|
CHECK_FALSE(variable.is_valid());
|
||||||
CHECK(variable == clazz_1_type.get_variable("non-existent-variable"));
|
CHECK(variable == clazz_1_type.get_variable("non-existent-variable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ TEST_CASE("meta/meta_types/any_type") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::any_type type{};
|
const meta::any_type type{};
|
||||||
CHECK_FALSE(type);
|
CHECK_FALSE(type);
|
||||||
CHECK(type.is_empty());
|
CHECK_FALSE(type.is_valid());
|
||||||
|
|
||||||
CHECK_FALSE(type.is_array());
|
CHECK_FALSE(type.is_array());
|
||||||
CHECK_FALSE(type.as_array());
|
CHECK_FALSE(type.as_array());
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ TEST_CASE("meta/meta_types/array_type") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::array_type type;
|
const meta::array_type type;
|
||||||
CHECK_FALSE(type);
|
CHECK_FALSE(type);
|
||||||
CHECK(type.is_empty());
|
CHECK_FALSE(type.is_valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("int[]") {
|
SUBCASE("int[]") {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ TEST_CASE("meta/meta_types/function_type") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::function_type type;
|
const meta::function_type type;
|
||||||
CHECK_FALSE(type);
|
CHECK_FALSE(type);
|
||||||
CHECK(type.is_empty());
|
CHECK_FALSE(type.is_valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("arg_copy") {
|
SUBCASE("arg_copy") {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ TEST_CASE("meta/meta_types/member_type") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::member_type type;
|
const meta::member_type type;
|
||||||
CHECK_FALSE(type);
|
CHECK_FALSE(type);
|
||||||
CHECK(type.is_empty());
|
CHECK_FALSE(type.is_valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("int") {
|
SUBCASE("int") {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ TEST_CASE("meta/meta_types/method_type") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::method_type type;
|
const meta::method_type type;
|
||||||
CHECK_FALSE(type);
|
CHECK_FALSE(type);
|
||||||
CHECK(type.is_empty());
|
CHECK_FALSE(type.is_valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("ivec2::at") {
|
SUBCASE("ivec2::at") {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ TEST_CASE("meta/meta_types/number_type") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::number_type type;
|
const meta::number_type type;
|
||||||
CHECK_FALSE(type);
|
CHECK_FALSE(type);
|
||||||
CHECK(type.is_empty());
|
CHECK_FALSE(type.is_valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("int") {
|
SUBCASE("int") {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ TEST_CASE("meta/meta_types/pointer_type") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::pointer_type type;
|
const meta::pointer_type type;
|
||||||
CHECK_FALSE(type);
|
CHECK_FALSE(type);
|
||||||
CHECK(type.is_empty());
|
CHECK_FALSE(type.is_valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("int*") {
|
SUBCASE("int*") {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ TEST_CASE("meta/meta_types/reference_type") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::reference_type type;
|
const meta::reference_type type;
|
||||||
CHECK_FALSE(type);
|
CHECK_FALSE(type);
|
||||||
CHECK(type.is_empty());
|
CHECK_FALSE(type.is_valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("int&") {
|
SUBCASE("int&") {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ TEST_CASE("meta/meta_types/void_type") {
|
|||||||
SUBCASE("") {
|
SUBCASE("") {
|
||||||
const meta::void_type type;
|
const meta::void_type type;
|
||||||
CHECK_FALSE(type);
|
CHECK_FALSE(type);
|
||||||
CHECK(type.is_empty());
|
CHECK_FALSE(type.is_valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("void") {
|
SUBCASE("void") {
|
||||||
|
|||||||
@@ -60,12 +60,12 @@ namespace meta_hpp::detail
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool is_empty() const noexcept {
|
[[nodiscard]] bool is_valid() const noexcept {
|
||||||
return vtable_ == nullptr;
|
return vtable_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] explicit operator bool() const noexcept {
|
[[nodiscard]] explicit operator bool() const noexcept {
|
||||||
return vtable_ != nullptr;
|
return is_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
R operator()(Args... args) const {
|
R operator()(Args... args) const {
|
||||||
|
|||||||
@@ -50,12 +50,12 @@ namespace meta_hpp::detail
|
|||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool is_empty() const noexcept {
|
[[nodiscard]] bool is_valid() const noexcept {
|
||||||
return data_ == nullptr;
|
return data_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] explicit operator bool() const noexcept {
|
[[nodiscard]] explicit operator bool() const noexcept {
|
||||||
return data_ != nullptr;
|
return is_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() noexcept {
|
void reset() noexcept {
|
||||||
|
|||||||
@@ -133,12 +133,12 @@ namespace meta_hpp
|
|||||||
state_base& operator=(state_base&&) noexcept = default;
|
state_base& operator=(state_base&&) noexcept = default;
|
||||||
state_base& operator=(const state_base&) = default;
|
state_base& operator=(const state_base&) = default;
|
||||||
|
|
||||||
[[nodiscard]] bool is_empty() const noexcept {
|
[[nodiscard]] bool is_valid() const noexcept {
|
||||||
return state_ == nullptr;
|
return state_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] explicit operator bool() const noexcept {
|
[[nodiscard]] explicit operator bool() const noexcept {
|
||||||
return state_ != nullptr;
|
return is_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const index_type& get_index() const noexcept {
|
[[nodiscard]] const index_type& get_index() const noexcept {
|
||||||
@@ -399,7 +399,7 @@ namespace std
|
|||||||
template < meta_hpp::detail::state_family State >
|
template < meta_hpp::detail::state_family State >
|
||||||
struct hash<State> {
|
struct hash<State> {
|
||||||
size_t operator()(const State& state) const noexcept {
|
size_t operator()(const State& state) const noexcept {
|
||||||
return state.is_empty() ? 0 : state.get_index().get_hash();
|
return state.is_valid() ? state.get_index().get_hash() : 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -408,15 +408,15 @@ namespace meta_hpp
|
|||||||
{
|
{
|
||||||
template < detail::state_family L, detail::state_family R >
|
template < detail::state_family L, detail::state_family R >
|
||||||
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
||||||
return l.is_empty() == r.is_empty() && (l.is_empty() || l.get_index() == r.get_index());
|
return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_index() == r.get_index());
|
||||||
}
|
}
|
||||||
|
|
||||||
template < detail::state_family L, detail::state_family R >
|
template < detail::state_family L, detail::state_family R >
|
||||||
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
||||||
if ( const std::strong_ordering cmp{!l.is_empty() <=> !r.is_empty()}; cmp != std::strong_ordering::equal ) {
|
if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) {
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
return l.is_empty() ? std::strong_ordering::equal : l.get_index() <=> r.get_index();
|
return l.is_valid() ? l.get_index() <=> r.get_index() : std::strong_ordering::equal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,12 +424,12 @@ namespace meta_hpp
|
|||||||
{
|
{
|
||||||
template < detail::state_family L, detail::index_family R >
|
template < detail::state_family L, detail::index_family R >
|
||||||
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
||||||
return !l.is_empty() && l.get_index() == r;
|
return l.is_valid() && l.get_index() == r;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < detail::state_family L, detail::index_family R >
|
template < detail::state_family L, detail::index_family R >
|
||||||
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
||||||
return !l.is_empty() ? l.get_index() <=> r : std::strong_ordering::less;
|
return l.is_valid() ? l.get_index() <=> r : std::strong_ordering::less;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,12 +65,12 @@ namespace meta_hpp
|
|||||||
type_base& operator=(type_base&&) noexcept = default;
|
type_base& operator=(type_base&&) noexcept = default;
|
||||||
type_base& operator=(const type_base&) = default;
|
type_base& operator=(const type_base&) = default;
|
||||||
|
|
||||||
[[nodiscard]] bool is_empty() const noexcept {
|
[[nodiscard]] bool is_valid() const noexcept {
|
||||||
return data_ == nullptr;
|
return data_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] explicit operator bool() const noexcept {
|
[[nodiscard]] explicit operator bool() const noexcept {
|
||||||
return data_ != nullptr;
|
return is_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] type_id get_id() const noexcept {
|
[[nodiscard]] type_id get_id() const noexcept {
|
||||||
@@ -327,7 +327,7 @@ namespace std
|
|||||||
template < meta_hpp::detail::type_family Type >
|
template < meta_hpp::detail::type_family Type >
|
||||||
struct hash<Type> {
|
struct hash<Type> {
|
||||||
size_t operator()(const Type& type) const noexcept {
|
size_t operator()(const Type& type) const noexcept {
|
||||||
return type.is_empty() ? 0 : type.get_id().get_hash();
|
return type.is_valid() ? type.get_id().get_hash() : 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -336,15 +336,15 @@ namespace meta_hpp
|
|||||||
{
|
{
|
||||||
template < detail::type_family L, detail::type_family R >
|
template < detail::type_family L, detail::type_family R >
|
||||||
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
|
||||||
return l.is_empty() == r.is_empty() && (l.is_empty() || l.get_id() == r.get_id());
|
return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_id() == r.get_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
template < detail::type_family L, detail::type_family R >
|
template < detail::type_family L, detail::type_family R >
|
||||||
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
|
||||||
if ( const std::strong_ordering cmp{!l.is_empty() <=> !r.is_empty()}; cmp != std::strong_ordering::equal ) {
|
if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) {
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
return l.is_empty() ? std::strong_ordering::equal : l.get_id() <=> r.get_id();
|
return l.is_valid() ? l.get_id() <=> r.get_id() : std::strong_ordering::equal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,12 +352,12 @@ namespace meta_hpp
|
|||||||
{
|
{
|
||||||
template < detail::type_family L >
|
template < detail::type_family L >
|
||||||
[[nodiscard]] bool operator==(const L& l, type_id r) noexcept {
|
[[nodiscard]] bool operator==(const L& l, type_id r) noexcept {
|
||||||
return !l.is_empty() && l.get_id() == r;
|
return l.is_valid() && l.get_id() == r;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < detail::type_family L >
|
template < detail::type_family L >
|
||||||
[[nodiscard]] std::strong_ordering operator<=>(const L& l, type_id r) noexcept {
|
[[nodiscard]] std::strong_ordering operator<=>(const L& l, type_id r) noexcept {
|
||||||
return !l.is_empty() ? l.get_id() <=> r : std::strong_ordering::less;
|
return l.is_valid() ? l.get_id() <=> r : std::strong_ordering::less;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ namespace meta_hpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool class_type::is_base_of(const class_type& derived) const noexcept {
|
inline bool class_type::is_base_of(const class_type& derived) const noexcept {
|
||||||
if ( is_empty() || derived.is_empty() ) {
|
if ( !is_valid() || !derived.is_valid() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ namespace meta_hpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool class_type::is_derived_from(const class_type& base) const noexcept {
|
inline bool class_type::is_derived_from(const class_type& base) const noexcept {
|
||||||
if ( is_empty() || base.is_empty() ) {
|
if ( !is_valid() || !base.is_valid() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user