cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
print.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_CONTAINER_FUNCTIONS_PRINT_H
4#define pRC_CORE_CONTAINER_FUNCTIONS_PRINT_H
5
9
10namespace pRC
11{
12 template<class S>
13 static inline auto print(Allocation const alloc, S &&stream)
14 {
15 switch(alloc)
16 {
18 print("pRC::Allocation::Stack", stream);
19 break;
21 print("pRC::Allocation::Heap", stream);
22 break;
23 default:
24 print("pRC::Allocation::Unknown", stream);
25 break;
26 }
27 }
28
29 template<Size... Ns, class S>
30 static inline auto print(Subscripts<Ns...> const &a, S &&stream)
31 {
32 print(name<Subscripts<Ns...>>(), stream);
33
34 print("(", stream);
35 if constexpr(sizeof...(Ns) > 0)
36 {
37 print(a[0], stream);
38
39 expand(makeRange<Index, 1, sizeof...(Ns)>(),
40 [&a, &stream](auto const... seq)
41 {
42 ((print(", ", stream), print(a[seq], stream)), ...);
43 });
44 }
45 print(")", stream);
46 }
47
48 template<Allocation A, class T, Size... Ns, class S>
49 static inline auto print(CommonArray<A, T, Ns...> const &arg, S &&stream)
50 {
52 print(":\n", stream);
53 range<Sizes<Ns...>>(
54 [&arg, &stream](auto const... indices)
55 {
56 print(Subscripts<Ns...>(indices...), stream);
57
58 print(": ", stream);
59 print(arg(indices...), stream);
60 print('\n', stream);
61 });
62 }
63}
64#endif // pRC_CORE_CONTAINER_FUNCTIONS_PRINT_H
Definition declarations.hpp:12
Definition sequence.hpp:29
Definition subscripts.hpp:21
TN::Subscripts S
Definition externs_nonTT.hpp:9
pRC::Float<> T
Definition externs_nonTT.hpp:1
Definition cholesky.hpp:10
Size Index
Definition basics.hpp:32
std::size_t Size
Definition basics.hpp:31
static auto print(String< N > const &string, std::FILE *stream)
Definition print.hpp:18
static auto alloc(Size size, Size const alignment=cMaxDefaultAlignment)
Definition allocation.hpp:49
static constexpr auto makeRange()
Definition sequence.hpp:421
static constexpr auto name()
Definition type_name.hpp:11
static constexpr auto arg(T const &a)
Definition arg.hpp:11
static constexpr auto range(F &&f, Xs &&...args)
Definition range.hpp:18
Allocation
Definition allocation.hpp:18
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
Definition sequence.hpp:383