-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathostream_output.hxx
78 lines (66 loc) · 1.92 KB
/
ostream_output.hxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright David Browne 2020-2024.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
#include "dsga.hxx"
#include <iostream>
//
// iostream interface
//
template <bool Writable, dsga::dimensional_scalar T, std::size_t Count, typename Derived>
inline std::ostream &operator<<(std::ostream &o, const dsga::vector_base<Writable, T, Count, Derived> &v)
{
const Derived &derived = v.as_derived();
if constexpr (std::same_as<bool, T>)
{
o << std::boolalpha;
}
o << "[" << derived[0];
for (int i = 1; i < derived.length(); ++i)
o << ", " << derived[i];
return o << "]";
}
template <dsga::dimensional_scalar T, std::size_t Size>
inline std::ostream &operator<<(std::ostream &o, const dsga::basic_vector<T, Size> &v)
{
if constexpr (std::same_as<bool, T>)
{
o << std::boolalpha;
}
o << "[" << v[0];
for (int i = 1; i < v.length(); ++i)
o << ", " << v[i];
return o << "]";
}
template <dsga::dimensional_scalar T, std::size_t Size, std::size_t Count, std::size_t ...Is>
inline std::ostream &operator<<(std::ostream &o, const dsga::indexed_vector<T, Size, Count, Is...> &v)
{
if constexpr (std::same_as<bool, T>)
{
o << std::boolalpha;
}
o << "[" << v[0];
for (int i = 1; i < v.length(); ++i)
o << ", " << v[i];
return o << "]";
}
template <dsga::dimensional_scalar T, std::size_t Size>
inline std::ostream &operator<<(std::ostream &o, const dsga::storage_wrapper<T, Size> &v)
{
if constexpr (std::same_as<bool, T>)
{
o << std::boolalpha;
}
o << "[" << v[0];
for (int i = 1; i < v.length(); ++i)
o << ", " << v[i];
return o << "]";
}
template <dsga::floating_point_scalar T, std::size_t C, std::size_t R>
inline std::ostream &operator<<(std::ostream &o, const dsga::basic_matrix<T, C, R> &m)
{
o << "[" << m[0];
for (int i = 1; i < m.length(); ++i)
o << ", " << m[i];
return o << "]";
}