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{
25// clang-format off
26template <class T>
27struct IsNumber : std::bool_constant<std::is_arithmetic_v<T>> {};
28
29template <std::floating_point T>
30struct IsNumber<std::complex<T>> : std::true_type {};
31
32template <class T>
33struct IsComplex : std::false_type {};
34
35template <std::floating_point T>
36struct IsComplex<std::complex<T>> : std::true_type {};
37// clang-format on
38} // namespace vctr::detail
39
40namespace vctr::is
41{
42
44template <class T>
45concept number = detail::IsNumber<T>::value;
46
48template <class T>
49concept intNumber = std::is_integral_v<std::remove_cvref_t<T>>;
50
52template <class T>
53concept int32Number = intNumber<T> && sizeof (T) == 4;
54
56template <class T>
57concept int64Number = intNumber<T> && sizeof (T) == 8;
58
60template <class T>
61concept signedNumber = std::is_signed_v<std::remove_cvref_t<T>>;
62
64template <class T>
66
68// clang-format off
69template <class T>
71// clang-format on
72
74template <class T>
75concept realNumber = std::is_arithmetic_v<T>;
76
78template <class T>
79concept realFloatNumber = std::is_floating_point_v<std::remove_cvref_t<T>>;
80
82template <class T>
83concept complexFloatNumber = detail::IsComplex<std::remove_cvref_t<T>>::value;
84
86template <class T>
88
90template <class T>
91concept disabledConstant = std::same_as<DisabledConstant, T>;
92
93} // namespace vctr::is
Constrains a type to represent a complex valued floating point number (e.g.
Definition: NumericTypeConcepts.h:83
Constrains a type to be of the type DisabledConstant.
Definition: NumericTypeConcepts.h:91
Constrains a type to represent a real valued 32 bit integer number.
Definition: NumericTypeConcepts.h:53
Constrains a type to represent a real valued 64 bit integer number.
Definition: NumericTypeConcepts.h:57
Constrains a type to represent a real valued integer number.
Definition: NumericTypeConcepts.h:49
Constrains a type to represent a real valued or std::complex number type.
Definition: NumericTypeConcepts.h:45
Constrains a type to represent a real valued floating point number.
Definition: NumericTypeConcepts.h:79
Constrains a type to represent a real valued number.
Definition: NumericTypeConcepts.h:75
Constrains a type to represent a real or complex valued floating point number.
Definition: NumericTypeConcepts.h:87
Constrains a type to represent a real valued signed integer number.
Definition: NumericTypeConcepts.h:65
Constrains a type to represent a real valued signed number (e.g.
Definition: NumericTypeConcepts.h:61
Constrains a type to represent a real valued unsigned integer number.
Definition: NumericTypeConcepts.h:70