#pragma once

#include <utility>

namespace f4ll {

template <typename T> class initialized_singleton
{
public:
    static T &instance() { return *m_instance; }
    template <typename... args_t> static T &init(args_t &&...args)
    {
        static T instance{std::forward<args_t>(args)...};
        m_instance = &instance;
        return instance;
    }

protected:
    initialized_singleton() = default;
    initialized_singleton(const initialized_singleton &) = delete;
    initialized_singleton &operator=(const initialized_singleton &) = delete;
    static T *m_instance;
};

template <typename T> T *initialized_singleton<T>::m_instance = nullptr;

} //  namespace f1ll {
