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

@@ -0,0 +1,28 @@
#pragma once
namespace hack::utils
{
struct no_copy
{
no_copy() = default;
no_copy(const no_copy&&) = delete;
no_copy operator=(const no_copy&&) = delete;
};
struct no_move
{
no_move() = default;
no_move(no_move&&) = delete;
no_move operator=(no_move&&) = delete;
};
template<typename T>
struct singleton : public no_move, no_copy
{
static T& get_instance()
{
static T t;
return t;
}
};
}

View File

@@ -1,27 +1,42 @@
inc += include_directories('.')
headers = [
'hack/logger/logger.hpp',
'hack/algorithms/sort.hpp',
'hack/concepts/concepts.hpp',
'hack/containers/containers.hpp',
'hack/containers/set.hpp',
'hack/containers/utils.hpp',
'hack/containers/vector.hpp',
# 'hack/concepts/concepts.hpp',
# 'hack/iterators/associative_ostream_iterator.hpp',
# 'hack/iterators/sequence_ostream_iterator.hpp',
# 'hack/math/matrix.hpp',
# 'hack/math/max.hpp',
# 'hack/math/vector.hpp',
# 'hack/range/range.hpp',
# 'hack/range/range.hpp',
# 'hack/security/is_link.hpp',
# 'hack/security/is_string.hpp',
# 'hack/security/uuid.hpp',
# 'hack/security/validate_email.hpp',
# 'hack/string/string.hpp',
# 'hack/string/string_concat_helper.hpp',
# 'hack/string/utf8_len.hpp',
# 'hack/utils/func_query.hpp',
# 'hack/utils/utils.hpp',
# 'hack/view/color.hpp'
'hack/iterators/associative_ostream_iterator.hpp',
'hack/iterators/sequence_ostream_iterator.hpp',
'hack/logger/logger.hpp',
'hack/macros/macros.hpp',
'hack/math/matrix.hpp',
'hack/math/max.hpp',
'hack/math/vector.hpp',
'hack/memory/make_ptr.hpp',
'hack/security/is_link.hpp',
'hack/security/is_string.hpp',
'hack/security/uuid.hpp',
'hack/security/validate_email.hpp',
'hack/string/string.hpp',
'hack/string/string_concat_helper.hpp',
'hack/string/utf8_len.hpp',
'hack/utils/func_query.hpp',
'hack/utils/singleton.hpp',
'hack/utils/utils.hpp',
'hack/view/color.hpp'
]
sources = []