VCTR
Loading...
Searching...
No Matches
NumericTypeConcepts.h
1/*
2 ==============================================================================
3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
5 Copyright 2022- by sonible GmbH.
6
7 This file is part of VCTR - Versatile Container Templates Reconceptualized.
8
9 VCTR is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License version 3
11 only, as published by the Free Software Foundation.
12
13 VCTR is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License version 3 for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 version 3 along with VCTR. If not, see <https://www.gnu.org/licenses/>.
20 ==============================================================================
21*/
22
23namespace vctr::detail
24{
25template <class T>
26constexpr bool isNumber = std::is_arithmetic_v<T>;
27
28template <std::floating_point T>
29constexpr bool isNumber<std::complex<T>> = true;
30
31template <class T>
32constexpr bool isComplex = false;
33
34template <std::floating_point T>
35constexpr bool isComplex<std::complex<T>> = true;
36
37template <class>
38constexpr bool isStdRatio = false;
39
40template <intmax_t n, intmax_t d>
41constexpr bool isStdRatio<std::ratio<n, d>> = true;
42} // namespace vctr::detail
43
44namespace vctr::is
45{
46
48template <class T>
49concept number = detail::isNumber<T>;
50
52template <class T>
53concept intNumber = std::is_integral_v<std::remove_cvref_t<T>>;
54
56template <class T>
57concept int32Number = intNumber<T> && sizeof (T) == 4;
58
60template <class T>
61concept int64Number = intNumber<T> && sizeof (T) == 8;
62
64template <class T>
65concept signedNumber = std::is_signed_v<std::remove_cvref_t<T>>;
66
68template <class T>
70
72// clang-format off
73template <class T>
75// clang-format on
76
78template <class T>
79concept realNumber = std::is_arithmetic_v<T>;
80
82template <class T>
83concept realFloatNumber = std::is_floating_point_v<std::remove_cvref_t<T>>;
84
86template <class T>
87concept complexFloatNumber = detail::isComplex<std::remove_cvref_t<T>>;
88
90template <class T>
92
94template <class T>
95concept stdRatio = detail::isStdRatio<T>;
96
98template <class T>
99concept disabledConstant = std::same_as<DisabledConstant, T>;
100
101} // namespace vctr::is
Constrains a type to represent a complex valued floating point number (e.g.
Definition: NumericTypeConcepts.h:87
Constrains a type to be of the type DisabledConstant.
Definition: NumericTypeConcepts.h:99
Constrains a type to represent a real valued 32 bit integer number.
Definition: NumericTypeConcepts.h:57
Constrains a type to represent a real valued 64 bit integer number.
Definition: NumericTypeConcepts.h:61
Constrains a type to represent a real valued integer number.
Definition: NumericTypeConcepts.h:53
Constrains a type to represent a real valued or std::complex number type.
Definition: NumericTypeConcepts.h:49
Constrains a type to represent a real valued floating point number.
Definition: NumericTypeConcepts.h:83
Constrains a type to represent a real valued number.
Definition: NumericTypeConcepts.h:79
Constrains a type to represent a real or complex valued floating point number.
Definition: NumericTypeConcepts.h:91
Constrains a type to represent a real valued signed integer number.
Definition: NumericTypeConcepts.h:69
Constrains a type to represent a real valued signed number (e.g.
Definition: NumericTypeConcepts.h:65
Constrains a type to be any std::ratio.
Definition: NumericTypeConcepts.h:95
Constrains a type to represent a real valued unsigned integer number.
Definition: NumericTypeConcepts.h:74