concepts: add numeric

This commit is contained in:
Danny Robson 2020-02-18 12:18:26 +11:00
parent 706e77f44a
commit c5174c2817

View File

@ -227,6 +227,21 @@ namespace cruft::concepts {
///////////////////////////////////////////////////////////////////////////////
// Some handy non-standard concepts
namespace cruft::concepts {
template <class T>
template <typename T>
concept arithmetic = std::is_arithmetic_v<T>;
/// A type that supports arithmetic operators.
template <typename T>
concept numeric = requires (T t)
{
{ t * t } -> convertible_to<T>;
{ t / t } -> convertible_to<T>;
{ t - t } -> convertible_to<T>;
{ t + t } -> convertible_to<T>;
};
template <typename T>
concept scalar = std::is_scalar_v<T>;
}