delpi  0.0.1
DElta-complete LP solver
Loading...
Searching...
No Matches
concepts.h
1
9#pragma once
10
11#include <concepts>
12
13namespace delpi {
14
26template <class T, typename From, typename To>
27concept MapFromTo = requires(T t) {
28 { t.at(From{}) } -> std::convertible_to<To>;
29}; // NOLINT(readability/braces) per C++ standard concept definition
30
42template <class T>
43concept SelfReferenceCounter = requires(T t) {
44 { t.AddRef() }; // NOLINT(readability/braces) per C++ standard concept definition
45 { t.Release() }; // NOLINT(readability/braces) per C++ standard concept definition
46}; // NOLINT(readability/braces) per C++ standard concept definition
47
56template <class T>
57concept Iterable = requires(T t) {
58 { t.begin() } -> std::convertible_to<typename T::iterator>;
59 { t.end() } -> std::convertible_to<typename T::iterator>;
60}; // NOLINT(readability/braces) per C++ standard concept definition
61
70template <class T>
71concept SizedIterable = requires(T t) {
72 { t.begin() } -> std::convertible_to<typename T::iterator>;
73 { t.end() } -> std::convertible_to<typename T::iterator>;
74 { t.size() } -> std::convertible_to<std::size_t>;
75}; // NOLINT(readability/braces) per C++ standard concept definition
76
86template <typename T, typename U>
87concept TypedIterable = requires(T t, U u) {
88 { t.begin() } -> std::convertible_to<typename T::iterator>;
89 { t.end() } -> std::convertible_to<typename T::iterator>;
90} && std::convertible_to<typename T::value_type, U>;
91
101template <typename T, typename U>
102concept SizedTypedIterable = requires(T t, U u) {
103 { t.begin() } -> std::convertible_to<typename T::iterator>;
104 { t.end() } -> std::convertible_to<typename T::iterator>;
105 { t.size() } -> std::convertible_to<std::size_t>;
106} && std::convertible_to<typename T::value_type, U>;
107
117template <typename T, typename... U>
118concept IsAnyOf = (std::same_as<T, U> || ...);
119
129template <typename T, typename... U>
130concept IsNotAnyOf = !IsAnyOf<T, U...>;
131
140template <class T>
141concept Arithmetic = requires(T a, T b) {
142 { a + b } -> std::convertible_to<T>;
143 { a - b } -> std::convertible_to<T>;
144 { a* b } -> std::convertible_to<T>;
145 { a / b } -> std::convertible_to<T>;
146}; // NOLINT(readability/braces) per C++ standard concept definition
147
157template <class T>
158concept Numeric = std::totally_ordered<T> && Arithmetic<T>;
159
160} // namespace delpi
Check if the type T supports the arithmetic operations +, -, *, /.
Definition concepts.h:141
Check if the type T is any of the types U.
Definition concepts.h:118
Check if the type T is not any of the types U.
Definition concepts.h:130
Check if the type T is an iterable type.
Definition concepts.h:57
Check if the type T constitutes a map from type From to type To.
Definition concepts.h:27
Check if the type T supports the arithmetic operations +, -, *, / and the comparison operators <,...
Definition concepts.h:158
Check if the type T is a self-reference counter type.
Definition concepts.h:43
Check if the type T is an iterable type with a size() method.
Definition concepts.h:71
Check if the type T is an iterable type with elements of type U and a size() method.
Definition concepts.h:102
Check if the type T is an iterable type with elements of type U.
Definition concepts.h:87
Global namespace for the delpi library.