aGrUM
3.3.2
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
concepts.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
41
48
#ifndef GUM_CONCEPTS_H
49
#define GUM_CONCEPTS_H
50
51
#include <concepts>
52
#include <limits>
53
54
#include <type_traits>
55
56
namespace
gum
{
57
60
69
template
<
typename
T >
70
concept
GUM_HasNumericLimits
=
requires
{
71
{ std::numeric_limits< T >::min() } -> std::convertible_to< T >;
72
{ std::numeric_limits< T >::max() } -> std::convertible_to< T >;
73
{ std::numeric_limits< T >::infinity() } -> std::convertible_to< T >;
74
{ std::numeric_limits< T >::is_specialized } -> std::convertible_to< bool >;
75
};
76
97
template
<
typename
T >
98
concept
GUM_IsGumScalar
99
= std::is_arithmetic_v< T >
100
|| (
101
// Custom numeric type requirements:
102
103
// Must be copyable and movable
104
std::copyable< T > && std::movable< T > &&
105
106
// Must be default constructible (for containers)
107
std::default_initializable< T > &&
108
109
// Must be constructible from common numeric literals
110
std::constructible_from< T, int > && std::constructible_from< T, double > &&
111
112
// Must support all arithmetic operations
113
requires
(T a, T b) {
114
{ a + b } -> std::convertible_to< T >;
115
{ a - b } -> std::convertible_to< T >;
116
{ a * b } -> std::convertible_to< T >;
117
{ a / b } -> std::convertible_to< T >;
118
{ a += b } -> std::same_as< T& >;
119
{ a *= b } -> std::same_as< T& >;
120
{ -a } -> std::convertible_to< T >;
// unary minus
121
} &&
122
123
// Must be totally ordered (supports <, >, <=, >=, ==, !=)
124
std::totally_ordered< T >);
125
147
template
<
typename
T >
148
concept
GUM_Numeric
=
GUM_IsGumScalar< T >
&&
GUM_HasNumericLimits< T >
;
149
151
152
}
// namespace gum
153
154
#endif
// GUM_CONCEPTS_H
gum::GUM_HasNumericLimits
Concept checking that std::numeric_limits is specialized for a type.
Definition
concepts.h:70
gum::GUM_IsGumScalar
Concept defining requirements for scalar types used as GUM_SCALAR.
Definition
concepts.h:99
gum::GUM_Numeric
Complete concept for GUM_SCALAR template parameter.
Definition
concepts.h:148
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
aGrUM
3.3.2
© PHW&CG&others - 2022
DoXyGeN 1.18.0