1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-03 04:33:30 -05:00
polybar/include/utils/factory.hpp

27 lines
508 B
C++
Raw Normal View History

2016-11-20 17:04:31 -05:00
#pragma once
2016-12-03 10:44:08 -05:00
#include <unistd.h>
2016-11-20 17:04:31 -05:00
#include "common.hpp"
POLYBAR_NS
namespace factory_util {
namespace detail {
struct null_deleter {
template <typename T>
void operator()(T*) const {}
};
} // namespace detail
extern detail::null_deleter null_deleter;
template <class T, class... Deps>
shared_ptr<T> singleton(Deps&&... deps) {
static shared_ptr<T> instance{make_shared<T>(forward<Deps>(deps)...)};
2016-11-20 17:04:31 -05:00
return instance;
}
} // namespace factory_util
2016-11-20 17:04:31 -05:00
POLYBAR_NS_END