add new concepts and error and warn logger

This commit is contained in:
2025-09-10 12:05:43 +03:00
parent 057dc595ac
commit 626b5a6cd9
9 changed files with 209 additions and 377 deletions

View File

@@ -1,3 +1,4 @@
#include <set>
#include "hack/concepts/concepts.hpp"
#include "hack/logger/logger.hpp"
@@ -108,12 +109,6 @@ void example_is_any_container(const T& container)
hack::log()("Any container with ", container.size(), " elements");
}
template<hack::concepts::is_iterable T>
void example_is_iterable(const T& iterable)
{
hack::log()("Iterable object");
}
template<hack::concepts::is_sized T>
void example_is_sized(const T& sized)
{
@@ -132,12 +127,6 @@ void check_support(const T& value)
hack::log()("Type is supported");
}
template<hack::concepts::is_contiguous_container T>
void example_is_contiguous_container(const T& container)
{
hack::log()("Contiguous memory container");
}
template<typename Container, typename Value>
requires hack::concepts::can_push_front<Container, Value>
void example_can_push_front(Container& container, Value&& value)
@@ -200,11 +189,9 @@ auto main(int argc, char *argv[]) -> int
example_is_fixed_array(fixed_array);
example_is_std_array(std_array);
example_is_any_container(vec);
example_is_iterable(vec);
example_is_sized(vec);
check_support(a);
check_support(custom);
example_is_contiguous_container(vec);
example_can_push_front(list, 0);
example_can_push_back(vec, 99);
example_can_find(set, 3);

View File

@@ -3,6 +3,7 @@
#include <unordered_set>
#include <map>
#include "hack/logger/logger.hpp"
#include "hack/patterns/ring_buffer.hpp"
auto main(int argc, char *argv[]) -> int
{
@@ -24,6 +25,9 @@ auto main(int argc, char *argv[]) -> int
sti.push(3);
std::set<int> si = { 1, 2, 3 };
std::unordered_set<int> usi = { 1, 1, 1 };
hack::patterns::ring_buffer<int> rb;
rb.create(10);
for (int i = 0; i < 10; ++i) rb.put(i);
hack::log().set_devider(", ");
hack::log().no_func();
@@ -53,7 +57,13 @@ auto main(int argc, char *argv[]) -> int
hack::log().reset();
hack::log().set_devider(", ");
hack::log()(sti, 123, true);
hack::log().reset();
hack::log()("log", 123, sti, false, 1.8f, vs);
hack::warn()("warn");
hack::error()("error");
hack::log()(rb);
return 0;
}

View File

@@ -5,7 +5,7 @@ executable(
# 'examples/math/main.cpp',
# 'examples/range/main.cpp',
# 'examples/patterns/main.cpp',
'examples/logger/main.cpp',
'examples/logger/main.cpp',
dependencies : deps,
cpp_args: args,
include_directories : inc