add singleton template

This commit is contained in:
chatlanin
2023-08-16 10:16:30 +03:00
parent 86ac6b451d
commit 05e856f42d
4 changed files with 76 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
executable(
'hack',
'algorithms/main.cpp',
'utils/main.cpp',
dependencies : deps,
cpp_args: args,
include_directories : inc

View File

@@ -2,6 +2,7 @@
#include "hack/logger/logger.hpp"
#include "hack/utils/utils.hpp"
#include "hack/utils/singleton.hpp"
#include "hack/utils/func_query.hpp"
int f(int a)
@@ -32,6 +33,14 @@ struct counter_test_2
int id;
};
struct test_singleton : public hack::utils::singleton<test_singleton>
{
void print()
{
hack::log()("Print singleton");
}
};
auto main(int argc, char *argv[]) -> int
{
{// ex: utils::func_memory
@@ -83,6 +92,10 @@ auto main(int argc, char *argv[]) -> int
query = hack::utils::make_query("super_function");
hack::log()("query", query);
}
{// ex: singleton
test_singleton::get_instance().print();
}
}