1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:27:35 +00:00

Revert "AK: Get rid of make_singleton function"

This reverts commit 5a98e329d1.
This commit is contained in:
Andreas Kling 2020-08-22 16:34:14 +02:00
parent 8a21491d86
commit 68580d5a8d
31 changed files with 46 additions and 42 deletions

View file

@ -39,18 +39,9 @@
namespace AK {
template<typename T>
struct SingletonInstanceCreator {
static T* create()
{
return new T();
}
};
template<typename T, T* (*InitFunction)() = SingletonInstanceCreator<T>::create>
template<typename T, T* (*InitFunction)()>
class Singleton {
AK_MAKE_NONCOPYABLE(Singleton);
AK_MAKE_NONMOVABLE(Singleton);
public:
Singleton() = default;
@ -119,4 +110,18 @@ private:
mutable T* m_obj { nullptr }; // atomic
};
template<typename T>
struct SingletonInstanceCreator {
static T* create()
{
return new T();
}
};
template<typename T>
inline Singleton<T, SingletonInstanceCreator<T>::create> make_singleton()
{
return Singleton<T, SingletonInstanceCreator<T>::create>();
}
}