Skip to content

Commit 6b9ed75

Browse files
committed
multiset
1 parent e89ba48 commit 6b9ed75

File tree

1 file changed

+55
-45
lines changed

1 file changed

+55
-45
lines changed

output.hpp

+55-45
Original file line numberDiff line numberDiff line change
@@ -25,126 +25,136 @@
2525
#include <boost/array.hpp>
2626
#endif
2727

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)
3029
{
31-
os << algocpp::type::format(v);
30+
os << algocpp::string::utf32conv.to_bytes(s);
3231

3332
return os;
3433
}
3534

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)
3836
{
39-
os << algocpp::type::format(v);
37+
os << std::u32string{c};
4038

4139
return os;
4240
}
4341

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)
4843
{
49-
os << algocpp::type::format(v);
44+
os << algocpp::string::utf16conv.to_bytes(s);
5045

5146
return os;
5247
}
5348

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)
5850
{
59-
os << algocpp::type::format(v);
51+
os << std::u16string{c};
6052

6153
return os;
6254
}
6355

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)
6657
{
67-
os << algocpp::type::format(p);
58+
os << algocpp::string::wstrconv.to_bytes(s);
6859

6960
return os;
7061
}
7162

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)
7464
{
75-
os << algocpp::type::format(x);
65+
os << std::wstring{c};
7666

7767
return os;
7868
}
7969

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)
8274
{
83-
os << algocpp::type::format(x);
75+
os << std::string(s.begin(), s.end());
8476

8577
return os;
8678
}
8779

88-
std::ostream &operator<<(std::ostream &os, const std::u32string &s)
80+
std::ostream &operator<<(std::ostream &os, const char8_t &c)
8981
{
90-
os << algocpp::string::utf32conv.to_bytes(s);
82+
os << std::u8string{c};
9183

9284
return os;
9385
}
9486

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)
9693
{
97-
os << std::u32string{c};
94+
os << algocpp::type::format(v);
9895

9996
return os;
10097
}
10198

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)
103101
{
104-
os << algocpp::string::utf16conv.to_bytes(s);
102+
os << algocpp::type::format(v);
105103

106104
return os;
107105
}
108106

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)
110111
{
111-
os << std::u16string{c};
112+
os << algocpp::type::format(v);
112113

113114
return os;
114115
}
115116

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)
117121
{
118-
os << algocpp::string::wstrconv.to_bytes(s);
122+
os << algocpp::type::format(v);
119123

120124
return os;
121125
}
122126

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)
124129
{
125-
os << std::wstring{c};
130+
os << algocpp::type::format(p);
126131

127132
return os;
128133
}
129134

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)
134137
{
135-
os << std::string(s.begin(), s.end());
138+
os << algocpp::type::format(x);
136139

137140
return os;
138141
}
139142

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)
141145
{
142-
os << std::u8string{c};
146+
os << algocpp::type::format(x);
143147

144148
return os;
145149
}
146150

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+
}
148158

149159
template <typename T1, typename T2>
150160
std::ostream &operator<<(std::ostream &os, const std::map<T1, T2> &x)

0 commit comments

Comments
 (0)