|
25 | 25 | #include <boost/array.hpp>
|
26 | 26 | #endif
|
27 | 27 |
|
28 |
| -template <typename T> |
29 |
| -std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) |
| 28 | +std::ostream &operator<<(std::ostream &os, const std::u32string &s) |
30 | 29 | {
|
31 |
| - os << algocpp::type::format(v); |
| 30 | + os << algocpp::string::utf32conv.to_bytes(s); |
32 | 31 |
|
33 | 32 | return os;
|
34 | 33 | }
|
35 | 34 |
|
36 |
| -template <typename T, std::size_t x> |
37 |
| -std::ostream &operator<<(std::ostream &os, const std::array<T, x> &v) |
| 35 | +std::ostream &operator<<(std::ostream &os, const char32_t &c) |
38 | 36 | {
|
39 |
| - os << algocpp::type::format(v); |
| 37 | + os << std::u32string{c}; |
40 | 38 |
|
41 | 39 | return os;
|
42 | 40 | }
|
43 | 41 |
|
44 |
| -#ifdef BOOST_ARRAY_HPP |
45 |
| - |
46 |
| -template <typename T, std::size_t n> |
47 |
| -std::ostream &operator<<(std::ostream &os, const boost::array<T, n> &v) |
| 42 | +std::ostream &operator<<(std::ostream &os, const std::u16string &s) |
48 | 43 | {
|
49 |
| - os << algocpp::type::format(v); |
| 44 | + os << algocpp::string::utf16conv.to_bytes(s); |
50 | 45 |
|
51 | 46 | return os;
|
52 | 47 | }
|
53 | 48 |
|
54 |
| -#endif |
55 |
| - |
56 |
| -template <typename T> |
57 |
| -std::ostream &operator<<(std::ostream &os, const std::list<T> &v) |
| 49 | +std::ostream &operator<<(std::ostream &os, const char16_t &c) |
58 | 50 | {
|
59 |
| - os << algocpp::type::format(v); |
| 51 | + os << std::u16string{c}; |
60 | 52 |
|
61 | 53 | return os;
|
62 | 54 | }
|
63 | 55 |
|
64 |
| -template <typename T1, typename T2> |
65 |
| -std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &p) |
| 56 | +std::ostream &operator<<(std::ostream &os, const std::wstring &s) |
66 | 57 | {
|
67 |
| - os << algocpp::type::format(p); |
| 58 | + os << algocpp::string::wstrconv.to_bytes(s); |
68 | 59 |
|
69 | 60 | return os;
|
70 | 61 | }
|
71 | 62 |
|
72 |
| -template <typename T> |
73 |
| -std::ostream &operator<<(std::ostream &os, const std::set<T> &x) |
| 63 | +std::ostream &operator<<(std::ostream &os, const wchar_t &c) |
74 | 64 | {
|
75 |
| - os << algocpp::type::format(x); |
| 65 | + os << std::wstring{c}; |
76 | 66 |
|
77 | 67 | return os;
|
78 | 68 | }
|
79 | 69 |
|
80 |
| -template <typename T> |
81 |
| -std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &x) |
| 70 | +// C++20 |
| 71 | +#if __cplusplus >= 202002LL |
| 72 | + |
| 73 | +std::ostream &operator<<(std::ostream &os, const std::u8string &s) |
82 | 74 | {
|
83 |
| - os << algocpp::type::format(x); |
| 75 | + os << std::string(s.begin(), s.end()); |
84 | 76 |
|
85 | 77 | return os;
|
86 | 78 | }
|
87 | 79 |
|
88 |
| -std::ostream &operator<<(std::ostream &os, const std::u32string &s) |
| 80 | +std::ostream &operator<<(std::ostream &os, const char8_t &c) |
89 | 81 | {
|
90 |
| - os << algocpp::string::utf32conv.to_bytes(s); |
| 82 | + os << std::u8string{c}; |
91 | 83 |
|
92 | 84 | return os;
|
93 | 85 | }
|
94 | 86 |
|
95 |
| -std::ostream &operator<<(std::ostream &os, const char32_t &c) |
| 87 | +#endif |
| 88 | + |
| 89 | +// ================================================================= |
| 90 | + |
| 91 | +template <typename T> |
| 92 | +std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) |
96 | 93 | {
|
97 |
| - os << std::u32string{c}; |
| 94 | + os << algocpp::type::format(v); |
98 | 95 |
|
99 | 96 | return os;
|
100 | 97 | }
|
101 | 98 |
|
102 |
| -std::ostream &operator<<(std::ostream &os, const std::u16string &s) |
| 99 | +template <typename T, std::size_t x> |
| 100 | +std::ostream &operator<<(std::ostream &os, const std::array<T, x> &v) |
103 | 101 | {
|
104 |
| - os << algocpp::string::utf16conv.to_bytes(s); |
| 102 | + os << algocpp::type::format(v); |
105 | 103 |
|
106 | 104 | return os;
|
107 | 105 | }
|
108 | 106 |
|
109 |
| -std::ostream &operator<<(std::ostream &os, const char16_t &c) |
| 107 | +#ifdef BOOST_ARRAY_HPP |
| 108 | + |
| 109 | +template <typename T, std::size_t n> |
| 110 | +std::ostream &operator<<(std::ostream &os, const boost::array<T, n> &v) |
110 | 111 | {
|
111 |
| - os << std::u16string{c}; |
| 112 | + os << algocpp::type::format(v); |
112 | 113 |
|
113 | 114 | return os;
|
114 | 115 | }
|
115 | 116 |
|
116 |
| -std::ostream &operator<<(std::ostream &os, const std::wstring &s) |
| 117 | +#endif |
| 118 | + |
| 119 | +template <typename T> |
| 120 | +std::ostream &operator<<(std::ostream &os, const std::list<T> &v) |
117 | 121 | {
|
118 |
| - os << algocpp::string::wstrconv.to_bytes(s); |
| 122 | + os << algocpp::type::format(v); |
119 | 123 |
|
120 | 124 | return os;
|
121 | 125 | }
|
122 | 126 |
|
123 |
| -std::ostream &operator<<(std::ostream &os, const wchar_t &c) |
| 127 | +template <typename T1, typename T2> |
| 128 | +std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &p) |
124 | 129 | {
|
125 |
| - os << std::wstring{c}; |
| 130 | + os << algocpp::type::format(p); |
126 | 131 |
|
127 | 132 | return os;
|
128 | 133 | }
|
129 | 134 |
|
130 |
| -// C++20 |
131 |
| -#if __cplusplus >= 202002LL |
132 |
| - |
133 |
| -std::ostream &operator<<(std::ostream &os, const std::u8string &s) |
| 135 | +template <typename T> |
| 136 | +std::ostream &operator<<(std::ostream &os, const std::set<T> &x) |
134 | 137 | {
|
135 |
| - os << std::string(s.begin(), s.end()); |
| 138 | + os << algocpp::type::format(x); |
136 | 139 |
|
137 | 140 | return os;
|
138 | 141 | }
|
139 | 142 |
|
140 |
| -std::ostream &operator<<(std::ostream &os, const char8_t &c) |
| 143 | +template <typename T> |
| 144 | +std::ostream &operator<<(std::ostream &os, const std::multiset<T> &x) |
141 | 145 | {
|
142 |
| - os << std::u8string{c}; |
| 146 | + os << algocpp::type::format(x); |
143 | 147 |
|
144 | 148 | return os;
|
145 | 149 | }
|
146 | 150 |
|
147 |
| -#endif |
| 151 | +template <typename T> |
| 152 | +std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &x) |
| 153 | +{ |
| 154 | + os << algocpp::type::format(x); |
| 155 | + |
| 156 | + return os; |
| 157 | +} |
148 | 158 |
|
149 | 159 | template <typename T1, typename T2>
|
150 | 160 | std::ostream &operator<<(std::ostream &os, const std::map<T1, T2> &x)
|
|
0 commit comments