mirror of https://github.com/RPCS3/rpcs3.git
fixed_typemap: implement need<> method
It may be used in constructors of other objects to assert a dependency. It also helps to ensure reverse destruction order of that dependency.
This commit is contained in:
parent
b35a5982e8
commit
5e59f18720
|
@ -29,11 +29,8 @@ struct vfs_manager
|
|||
|
||||
bool vfs::mount(std::string_view vpath, std::string_view path)
|
||||
{
|
||||
if (!g_fxo->get<vfs_manager>())
|
||||
{
|
||||
// Init (TODO)
|
||||
g_fxo->init<vfs_manager>();
|
||||
}
|
||||
// Workaround
|
||||
g_fxo->need<vfs_manager>();
|
||||
|
||||
const auto table = g_fxo->get<vfs_manager>();
|
||||
|
||||
|
|
|
@ -148,6 +148,16 @@ namespace stx
|
|||
}
|
||||
}
|
||||
|
||||
// Check if object is not initialized but shall be initialized first (to use in initializing other objects)
|
||||
template <typename T>
|
||||
void need() noexcept
|
||||
{
|
||||
if (!get<T>())
|
||||
{
|
||||
init<T>();
|
||||
}
|
||||
}
|
||||
|
||||
// Explicitly (re)initialize object of type T possibly with dynamic type As and arguments
|
||||
template <typename T, typename As = T, typename... Args>
|
||||
As* init(Args&&... args) noexcept
|
||||
|
|
Loading…
Reference in New Issue