Skip to content

Commit

Permalink
fix linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
n0lavar committed Jan 6, 2024
1 parent ae4cb75 commit f89a3f9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion include/qx/containers/components.inl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ component_t* components<base_component_t>::add(
pRawComponent,
[ePriority, statusFlags, pRawComponent](SClassData& classData)
{
classData.priorityCache.emplace(ePriority, SClassData::SCacheData(pRawComponent, statusFlags));
classData.priorityCache.emplace(ePriority, typename SClassData::SCacheData(pRawComponent, statusFlags));
});
classData.components.push_back(std::move(pComponent));
return pRawComponent;
Expand Down
13 changes: 5 additions & 8 deletions include/qx/patterns/contiguous_iterator/base_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
namespace qx
{

template<class container_t, class derived_t>
class base_forward_iterator;

template<class container_t, class derived_t>
class base_reverse_iterator;

/**
@class base_iterator
Expand All @@ -37,8 +31,11 @@ template<class container_t>
class base_iterator
{
public:
friend base_forward_iterator;
friend base_reverse_iterator;
template<class container_t_, class derived_t_>
friend class base_forward_iterator;

template<class container_t_, class derived_t_>
friend class base_reverse_iterator;

using difference_type = typename container_t::difference_type;
using size_type = typename container_t::size_type;
Expand Down
23 changes: 10 additions & 13 deletions include/qx/rtti/rtti.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,12 @@ concept has_get_class_id_static = requires(T t) { T::get_class_id_static(); };
@retval - class id
**/
template<class C>
inline class_identificator get_class_id() noexcept
constexpr class_identificator get_class_id() noexcept
{
if constexpr (details::has_get_class_id_static<C>)
{
return C::get_class_id_static();
}
else
{
return std::numeric_limits<class_identificator>::max();
}
}

// utility class to let you use std::derived_from
Expand Down Expand Up @@ -85,16 +81,17 @@ class rtti_root : public rtti_pure_base
rtti_root(const rtti_root&) noexcept = default;
rtti_root(rtti_root&&) noexcept = default;

template<class rtti_type>
template<class T>
bool is_derived_from() const noexcept
{
return _is_base_id(qx::get_class_id<rtti_type>()) || qx::get_class_id<rtti_type>() == get_class_id();
constexpr class_identificator T_id = qx::get_class_id<T>();
return _is_base_id(T_id) || T_id == get_class_id();
}

template<class rtti_type>
template<class T>
bool is() const noexcept
{
return get_class_id() == rtti_type::get_class_id_static();
return get_class_id() == T::get_class_id_static();
}

bool is(string_view svClassName) const noexcept
Expand Down Expand Up @@ -124,7 +121,7 @@ class rtti_root : public rtti_pure_base

static constexpr class_identificator get_class_id_static() noexcept
{
return 0;
return QX_STRING_HASH(QX_STRINGIFY(rtti_root));
}

virtual class_identificator get_class_id() const noexcept
Expand All @@ -136,7 +133,7 @@ class rtti_root : public rtti_pure_base

auto operator<=>(const rtti_root&) const = default;

protected:
//protected:
virtual ~rtti_root() noexcept = default;

virtual bool _is_base_id(class_identificator idBase) const noexcept
Expand Down Expand Up @@ -201,10 +198,10 @@ public:
return ids; \
} \
\
protected: \
/*protected:*/ \
virtual bool _is_base_id(qx::class_identificator base_id) const noexcept override \
{ \
return base_id == qx::get_class_id<super_class_type>() || super_class_type::_is_base_id(base_id); \
return base_id == super_class_type::get_class_id_static() || super_class_type::_is_base_id(base_id); \
} \
\
private:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_concepts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ class C3 : public C1<float>

static_assert(qx::derived_from_template_c<C2, C1>);
static_assert(qx::derived_from_template_c<C3, C1>);
static_assert(!qx::derived_from_template_c<C, C1>);
static_assert(!qx::derived_from_template_c<C<int>, C1>);
10 changes: 6 additions & 4 deletions tests/test_rtti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <qx/rtti/rtti_cast.h>

#include <memory>
#include <source_location>

class CClass1
{
Expand Down Expand Up @@ -196,14 +197,15 @@ TEST(rtti, class_id)
}

template<class T>
void TestDerivedFrom(const auto& pClass, bool bExpect)
void TestDerivedFrom(const auto& pClass, bool bExpect, std::source_location sr = std::source_location::current())
{
EXPECT_EQ(pClass->template is_derived_from<T>(), bExpect);
constexpr qx::class_identificator T_id = qx::get_class_id<T>();
EXPECT_EQ(pClass->template is_derived_from<T>(), bExpect)
<< "Line: " << sr.line() << ", pClass's id: " << pClass->get_class_id() << ", T id: " << qx::get_class_id<T>()
<< ", _is_base_id: " << pClass->_is_base_id(T_id);

if constexpr (qx::details::has_get_class_id_static<T>)
{
EXPECT_EQ(pClass->is_derived_from_id(T::get_class_id_static()), bExpect);
}
}

TEST(rtti, is_derived_from)
Expand Down

0 comments on commit f89a3f9

Please sign in to comment.