LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
Concepts.hpp
Go to the documentation of this file.
1
12#ifndef UTIL_CONCEPTS_HPP
13#define UTIL_CONCEPTS_HPP
14
15#include <concepts>
16#include <utility>
17#include <nlohmann/json.hpp>
18
23namespace util
24{
25
44template <typename T, typename... Args>
45concept Constructible = requires(Args&&... args) {
46 T(std::forward<Args>(args)...);
47};
48
70template <typename T>
71concept EventItemsLike = requires(T t) {
72 { t.size() } -> std::convertible_to<size_t>;
73 { t.begin() };
74 { t.end() };
75 requires std::is_same_v<typename T::value_type, std::pair<std::string, std::string>>;
76};
77
84template <typename T>
85concept Comparable = requires(const T& a, const T& b) {
86 { a == b } -> std::convertible_to<bool>;
87 { a != b } -> std::convertible_to<bool>;
88};
89
96template <typename T>
97concept Hashable = requires(const T& a) {
98 { std::hash<T>{}(a) } -> std::convertible_to<size_t>;
99};
100
107template <typename T>
108concept Orderable = Comparable<T> && requires(const T& a, const T& b) {
109 { a < b } -> std::convertible_to<bool>;
110 { a <= b } -> std::convertible_to<bool>;
111 { a > b } -> std::convertible_to<bool>;
112 { a >= b } -> std::convertible_to<bool>;
113};
114
121template <typename T>
122concept HasToString = requires(const T& t) {
123 { t.ToString() } -> std::convertible_to<std::string>;
124};
125
126} // namespace util
127
128#endif // UTIL_CONCEPTS_HPP
129
Matches types that can be compared for equality.
Definition Concepts.hpp:85
Matches types that can be constructed from the given arguments.
Definition Concepts.hpp:45
Matches types that behave like LogEvent's EventItems collection.
Definition Concepts.hpp:71
Matches types that provide a to_string() method.
Definition Concepts.hpp:122
Matches types that can be used as hash map keys.
Definition Concepts.hpp:97
Matches types that support ordering operations.
Definition Concepts.hpp:108
Utility components and helper types for the LogViewer application.