concepts: add scalar, enumeration, and iterable concepts
This commit is contained in:
parent
8f39ed706d
commit
455b3b973f
13
concepts.hpp
13
concepts.hpp
@ -232,6 +232,12 @@ namespace cruft::concepts {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
concept arithmetic = std::is_arithmetic_v<T>;
|
concept arithmetic = std::is_arithmetic_v<T>;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept scalar = std::is_scalar_v<T>;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept enumeration = std::is_enum_v<T>;
|
||||||
|
|
||||||
|
|
||||||
/// A type that supports arithmetic operators.
|
/// A type that supports arithmetic operators.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -244,6 +250,11 @@ namespace cruft::concepts {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// Anything that can be looped over using begin/end
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept scalar = std::is_scalar_v<T>;
|
concept iterable = requires (T t)
|
||||||
|
{
|
||||||
|
{ std::begin (t) } -> legacy_iterator;
|
||||||
|
{ std::end (t) } -> legacy_iterator;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user