ALP User Documentation 0.7.0
Algebraic Programming User Documentation
type_traits.hpp
Go to the documentation of this file.
1
2/*
3 * Copyright 2021 Huawei Technologies Co., Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
27#ifndef _H_GRB_TYPE_TRAITS
28#define _H_GRB_TYPE_TRAITS
29
30#include <type_traits>
31
32
33namespace grb {
34
46 template< typename T >
47 struct is_container {
48
54 static const constexpr bool value = false;
55
56 };
57
65 template< typename T >
66 struct is_semiring {
67
73 static const constexpr bool value = false;
74
75 };
76
84 template< typename T >
85 struct is_monoid {
86
92 static const constexpr bool value = false;
93
94 };
95
103 template< typename T >
104 struct is_operator {
105
111 static const constexpr bool value = false;
112 };
113
129 template< typename T >
130 struct is_object {
131
135 static const constexpr bool value = is_container< T >::value ||
139 };
140
160 template< typename T, typename = void >
162
164 "Template argument to grb::is_idempotent must be an operator or a monoid!" );
165
167 static const constexpr bool value = false;
168
169 };
170
178 template< typename Monoid >
179 struct is_idempotent<
180 Monoid,
181 typename std::enable_if< is_monoid< Monoid >::value, void >::type
182 > {
183 static const constexpr bool value =
185 };
186
201 template< typename T, typename = void >
203
205 "Template argument should be an ALP binary operator or monoid." );
206
208 static const constexpr bool value = false;
209
210 };
211
219 template< typename Monoid >
220 struct is_associative<
221 Monoid,
222 typename std::enable_if< is_monoid< Monoid >::value, void >::type
223 > {
225 "Malformed ALP monoid encountered" );
226 static const constexpr bool value = true;
227 };
228
239 template< typename T, typename = void >
241
243 "Template argument should be an ALP binary operator or monoid." );
244
246 static const constexpr bool value = false;
247
248 };
249
257 template< typename Monoid >
258 struct is_commutative<
259 Monoid,
260 typename std::enable_if< is_monoid< Monoid >::value, void >::type
261 > {
263 static const constexpr bool value =
265 };
266
278 template< typename T >
280
281 static_assert( is_semiring< T >::value,
282 "Template argument to grb::has_immutable_nonzeroes must be a "
283 "semiring!" );
284
286 static const constexpr bool value = false;
287
288 };
289
290 namespace internal {
291
304 template< typename OP >
305 struct maybe_noop {
306 static_assert( is_operator< OP >::value,
307 "Argument to internal::maybe_noop must be an operator."
308 );
309 static const constexpr bool value = false;
310 };
311
312 } // end namespace grb::internal
313
314} // namespace grb
315
316#endif // end _H_GRB_TYPE_TRAITS
317
A generalised monoid.
Definition: monoid.hpp:54
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:452
Used to inspect whether a given semiring has immutable nonzeroes under addition.
Definition: type_traits.hpp:279
static const constexpr bool value
Whether T a semiring where nonzeroes are immutable.
Definition: type_traits.hpp:286
Used to inspect whether a given operator or monoid is associative.
Definition: type_traits.hpp:202
static const constexpr bool value
Whether T is associative.
Definition: type_traits.hpp:208
Used to inspect whether a given operator or monoid is commutative.
Definition: type_traits.hpp:240
static const constexpr bool value
Whether T is commutative.
Definition: type_traits.hpp:246
Used to inspect whether a given type is an ALP/GraphBLAS container.
Definition: type_traits.hpp:47
static const constexpr bool value
Whether T is an ALP/GraphBLAS container.
Definition: type_traits.hpp:54
Used to inspect whether a given operator or monoid is idempotent.
Definition: type_traits.hpp:161
static const constexpr bool value
Wheter T is idempotent.
Definition: type_traits.hpp:167
Used to inspect whether a given type is an ALP monoid.
Definition: type_traits.hpp:85
static const constexpr bool value
Whether T is an ALP monoid.
Definition: type_traits.hpp:92
Used to inspect whether a given type is an ALP/GraphBLAS object.
Definition: type_traits.hpp:130
static const constexpr bool value
Whether the given time is an ALP/GraphBLAS object.
Definition: type_traits.hpp:135
Used to inspect whether a given type is an ALP operator.
Definition: type_traits.hpp:104
static const constexpr bool value
Whether T is an ALP operator.
Definition: type_traits.hpp:111
Used to inspect whether a given type is an ALP semiring.
Definition: type_traits.hpp:66
static const constexpr bool value
Whether T is an ALP semiring.
Definition: type_traits.hpp:73