12#include <forward_list>
18#include <system_error>
22#include <unordered_map>
23#include <unordered_set>
30extern std::unordered_map<std::type_index, std::function<std::string(
xtd::any const&)>> __any_stringer__;
32inline std::ostream& operator <<(std::ostream& os,
const std::exception& value) {
33 return os <<
"exception: " << value.what();
36template<
typename value_t>
38inline std::ostream& operator <<(std::ostream& os,
const std::optional<value_t>& value) {
39 if (!value.has_value())
return os <<
"(null)";
40 return os <<
"(" << value.value() <<
")";
43template<
typename value_t>
45inline std::ostream&
operator <<(std::ostream& os,
const std::optional<value_t>&) {
46 return os <<
"(unregistered)";
49template<
typename type1_t,
typename type2_t>
51inline std::ostream& operator <<(std::ostream& os,
const std::pair<type1_t, type2_t>& value) {
52 return os <<
"(" << value.first <<
", " << value.second <<
")";
55template<
typename type1_t,
typename type2_t>
57inline std::ostream&
operator <<(std::ostream& os,
const std::pair<type1_t, type2_t>& value) {
61template<
typename type_t,
unsigned n_t,
unsigned last_t>
63struct __xtd_console_tuple_printer {
64 static void print(std::ostream& os,
const type_t& value) {
65 os << std::get<n_t>(value);
66 if constexpr (n_t < last_t) os <<
", ";
67 if constexpr (n_t < last_t)
68 __xtd_console_tuple_printer<type_t, n_t + 1, last_t>::print(os, value);
72template<
typename ...types_t>
73inline std::ostream& operator <<(std::ostream& os,
const std::tuple<types_t ... >& value) {
75 __xtd_console_tuple_printer<std::tuple<types_t...>, 0,
sizeof...(types_t) - 1>::print(os, value);
88template<
typename iterator_t>
90inline void __xtd_console_print_container(std::ostream& os,
const iterator_t& begin,
const iterator_t& end) {
91 for (
auto it = begin; it !=
end; ++it) {
92 os << (it !=
begin ?
", " :
"") << *it;
96template<
typename iterator_t>
98inline void __xtd_console_print_container(std::ostream& os,
const iterator_t& begin,
const iterator_t& end) {
99 for (
auto it = begin; it !=
end; ++it) {
100 os << (it !=
begin ?
", " :
"") <<
" ";
104template<
typename iterator_t>
105inline std::ostream& __xtd_console_print_sequence_container(std::ostream& os,
const iterator_t& begin,
const iterator_t& end) {
107 __xtd_console_print_container(os, begin, end);
111template<
typename type_t,
size_t size_t>
112inline std::ostream& operator <<(std::ostream& os,
const std::array<type_t, size_t>& values) {
113 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
116template<
typename type_t,
typename allocator_t = std::allocator < type_t>>
117inline std::ostream& operator <<(std::ostream& os,
const std::deque<type_t, allocator_t>& values) {
118 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
121template<
typename type_t,
typename allocator_t = std::allocator<type_t>>
122inline std::ostream& operator <<(std::ostream& os,
const std::forward_list<type_t, allocator_t>& values) {
123 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
126template<
typename type_t>
127inline std::ostream& operator <<(std::ostream& os,
const std::initializer_list<type_t>& values) {
128 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
131template<
typename type_t,
typename allocator_t = std::allocator<type_t>>
132inline std::ostream& operator <<(std::ostream& os,
const std::list<type_t, allocator_t>& values) {
133 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
136template<
typename type_t>
137inline std::ostream& operator <<(std::ostream& os,
const std::valarray<type_t>& values) {
138 return __xtd_console_print_sequence_container(os, std::begin(values), std::end(values));
141template<
typename type_t,
typename allocator_t = std::allocator<type_t>>
142inline std::ostream& operator <<(std::ostream& os,
const std::vector<type_t, allocator_t>& values) {
143 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
146template<
typename iterator_t>
147inline std::ostream& __xtd_console_print_associative_container(std::ostream& os,
const iterator_t& begin,
const iterator_t& end) {
149 __xtd_console_print_container(os, begin, end);
153template<
typename key_t,
typename value_t,
typename compare_t = std::less <key_t>,
typename allocator_t = std::allocator<std::pair<const key_t, value_t>>>
154inline std::ostream& operator <<(std::ostream& os,
const std::map < key_t, value_t, compare_t, allocator_t >& values) {
155 return __xtd_console_print_associative_container(os, values.begin(), values.end());
158template<
typename key_t,
typename value_t,
typename compare_t = std::less <key_t>,
typename allocator_t = std::allocator<std::pair<const key_t, value_t>>>
159inline std::ostream& operator <<(std::ostream& os,
const std::multimap < key_t, value_t, compare_t, allocator_t >& values) {
160 return __xtd_console_print_associative_container(os, values.begin(), values.end());
163template<
typename key_t,
typename compare_t = std::less <key_t>,
typename allocator_t = std::allocator<key_t>>
164inline std::ostream& operator <<(std::ostream& os,
const std::multiset < key_t, compare_t, allocator_t >& values) {
165 return __xtd_console_print_associative_container(os, values.begin(), values.end());
168template <
class key_t,
typename compare_t = std::less < key_t>,
typename allocator_t = std::allocator<key_t >>
169inline std::ostream& operator <<(std::ostream& os,
const std::set < key_t, compare_t, allocator_t >& values) {
170 return __xtd_console_print_associative_container(os, values.begin(), values.end());
173template <
class key_t,
typename value_t,
typename pred_t = std::equal_to < key_t>,
typename allocator_t = std::allocator<std::pair<const key_t, value_t >>>
174inline std::ostream& operator <<(std::ostream& os,
const std::unordered_map < key_t, value_t, pred_t, allocator_t >& values) {
175 return __xtd_console_print_associative_container(os, values.begin(), values.end());
178template <
class key_t,
typename value_t,
typename pred_t = std::equal_to < key_t>,
typename allocator_t = std::allocator<std::pair<const key_t, value_t >>>
179inline std::ostream& operator <<(std::ostream& os,
const std::unordered_multimap < key_t, value_t, pred_t, allocator_t >& values) {
180 return __xtd_console_print_associative_container(os, values.begin(), values.end());
183template <
class key_t,
typename pred_t = std::equal_to < key_t>,
typename allocator_t = std::allocator<key_t >>
184std::ostream& operator <<(std::ostream& os,
const std::unordered_multiset < key_t, pred_t, allocator_t >& values) {
185 return __xtd_console_print_associative_container(os, values.begin(), values.end());
188template <
class key_t,
typename pred_t = std::equal_to < key_t>,
typename allocator_t = std::allocator<key_t >>
189inline std::ostream& operator <<(std::ostream& os,
const std::unordered_set < key_t, pred_t, allocator_t >& values) {
190 return __xtd_console_print_associative_container(os, values.begin(), values.end());
193inline std::ostream& operator <<(std::ostream& os,
const std::error_category& value) {
194 return os <<
"(" << value.name() <<
")";
197inline std::ostream& operator <<(std::ostream& os,
const std::error_code& value) {
198 return os <<
"(value = " << value.value() <<
"category= " << value.category().name() <<
")";
203 template<
typename type_t>
206auto operator << (std::ostream& os,
const xtd::iformatable& value) -> std::ostream&;
207template<
typename type_t>
209 return os << value.to_string();
Contains xtd::any type and std::bad_any_cast exception.
Provides a way to represent the current object as a string.
Definition istringable.hpp:26
Definition stream_insertable.hpp:13
std::any any
Represents the any alias on std::any.
Definition any.hpp:24
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
const_iterator begin() const
Returns an iterator to the beginning.
Definition read_only_span.hpp:183
const_iterator end() const
Returns an iterator to the end.
Definition read_only_span.hpp:213
void print(FILE *file, arg_t &&value)
Writes the text representation of the specified value to the file output stream.
Definition print.hpp:19
Contains xtd::optional type.
Contains xtd::stream_insertable concept.