mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-11 18:50:55 +00:00
typeindices.hpp: add typeindex() helper
This commit is contained in:
parent
c7bf6421f4
commit
3092914527
3 changed files with 10 additions and 3 deletions
|
@ -506,7 +506,7 @@ namespace utils
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typemap_head* get_head() const
|
typemap_head* get_head() const
|
||||||
{
|
{
|
||||||
return &m_map[stx::type_counter<typeinfo_base>::type<std::decay_t<T>>.index()];
|
return &m_map[stx::typeindex<typeinfo_base, std::decay_t<T>>()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -96,7 +96,7 @@ namespace stx
|
||||||
template <typename T, typename As = T, typename... Args>
|
template <typename T, typename As = T, typename... Args>
|
||||||
As* init(Args&&... args) noexcept
|
As* init(Args&&... args) noexcept
|
||||||
{
|
{
|
||||||
auto& ptr = m_list[stx::type_counter<typeinfo>::template type<std::decay_t<T>>.index()];
|
auto& ptr = m_list[stx::typeindex<typeinfo, std::decay_t<T>>()];
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
|
@ -112,7 +112,7 @@ namespace stx
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T* get() const noexcept
|
T* get() const noexcept
|
||||||
{
|
{
|
||||||
return static_cast<T*>(m_list[stx::type_counter<typeinfo>::template type<std::decay_t<T>>.index()]);
|
return static_cast<T*>(m_list[stx::typeindex<typeinfo, std::decay_t<T>>()]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,4 +123,11 @@ namespace stx
|
||||||
typelist_v<Info>.next->next = this;
|
typelist_v<Info>.next->next = this;
|
||||||
typelist_v<Info>.next = this;
|
typelist_v<Info>.next = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Type index accessor
|
||||||
|
template <typename Info, typename T>
|
||||||
|
inline unsigned typeindex() noexcept
|
||||||
|
{
|
||||||
|
return type_counter<Info>::template type<T>.index();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue