concepts: add scalar, enumeration, and iterable concepts

This commit is contained in:
Danny Robson 2020-02-24 14:37:32 +11:00
parent 8f39ed706d
commit 455b3b973f

View File

@ -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;
};
} }