concepts: add numeric
This commit is contained in:
parent
706e77f44a
commit
c5174c2817
17
concepts.hpp
17
concepts.hpp
@ -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>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user