smats  0.0.1
Satisfability Modulo Arithmetic Theories Symbols
Loading...
Searching...
No Matches
concepts.h
1
10#pragma once
11
12#include <concepts>
13
14namespace smats {
15
24template <class T>
25concept IsEnum = std::is_enum_v<T>;
26
36template <class T, class... U>
37concept IsAnyOf = (std::same_as<T, U> || ...);
38
48template <class T, class... U>
49concept IsNotAnyOf = !IsAnyOf<T, U...>;
50
59template <class T>
60concept Arithmetic = requires(T a, T b) {
61 { a + b } -> std::convertible_to<T>;
62 { a - b } -> std::convertible_to<T>;
63 { a* b } -> std::convertible_to<T>;
64 { a / b } -> std::convertible_to<T>;
65}; // NOLINT(readability/braces) per C++ standard concept definition
66
75template <class T>
76concept Numeric = std::totally_ordered<T> && Arithmetic<T>;
77
87template <class T>
88concept InvocableHashAlgorithm = requires(T t, const void* data, size_t length) {
89 typename T::result_type;
90 { t(data, length) } noexcept -> std::same_as<void>;
91 { size_t() } noexcept -> std::same_as<typename T::result_type>;
92}; // NOLINT(readability/braces) per C++ standard concept definition
93
100template <class T, class U>
101concept Hashable = requires(T t, U& hasher) {
102 { t.hash(hasher) } noexcept -> std::same_as<void>;
104
109template <class T>
110concept Spannable = std::ranges::contiguous_range<T> && std::ranges::sized_range<T>;
111
117template <class T, class U>
118concept SpannableOfType = Spannable<T> && std::same_as<U, std::ranges::range_value_t<T>>;
119
120} // namespace smats
Definition concepts.h:60
Definition concepts.h:101
Definition concepts.h:88
Definition concepts.h:37
Definition concepts.h:25
Definition concepts.h:49
Definition concepts.h:76
Definition concepts.h:118
Definition concepts.h:110
ExpressionKind enum.