12#include <forward_list>
18#include <system_error>
22#include <unordered_map>
23#include <unordered_set>
31extern std::unordered_map<std::type_index, std::function<std::string(
xtd::any const&)>> __any_stringer__;
33inline std::ostream& operator <<(std::ostream& os,
const std::exception& value) {
34 return os <<
"exception: " <<
value.what();
37template<
typename value_t>
39inline std::ostream& operator <<(std::ostream& os,
const std::optional<value_t>& value) {
40 if (!
value.has_value())
return os <<
"(null)";
41 return os <<
"(" <<
value.value() <<
")";
44template<
typename value_t>
46inline std::ostream&
operator <<(std::ostream& os,
const std::optional<value_t>&) {
47 return os <<
"(unregistered)";
50template<
typename type1_t,
typename type2_t>
52inline std::ostream& operator <<(std::ostream& os,
const std::pair<type1_t, type2_t>& value) {
53 return os <<
"(" <<
value.first <<
", " <<
value.second <<
")";
56template<
typename type1_t,
typename type2_t>
58inline std::ostream&
operator <<(std::ostream& os,
const std::pair<type1_t, type2_t>& value) {
62template<
typename type_t,
unsigned n_t,
unsigned last_t>
64struct __xtd_console_tuple_printer {
65 static void print(std::ostream& os,
const type_t& value) {
66 os << std::get<n_t>(value);
67 if constexpr (n_t < last_t) os <<
", ";
68 if constexpr (n_t < last_t)
69 __xtd_console_tuple_printer<type_t, n_t + 1, last_t>::print(os, value);
73template<
typename ...types_t>
74inline std::ostream& operator <<(std::ostream& os,
const std::tuple<types_t ... >& value) {
76 __xtd_console_tuple_printer<std::tuple<types_t...>, 0,
sizeof...(types_t) - 1>::print(os, value);
80template<
typename iterator_t>
82inline void __xtd_console_print_container(std::ostream& os,
const iterator_t& begin,
const iterator_t& end) {
83 for (
auto it = begin; it !=
end; ++it) {
84 os << (it !=
begin ?
", " :
"") << *it;
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 ?
", " :
"") <<
" ";
96template<
typename iterator_t>
97inline std::ostream& __xtd_console_print_sequence_container(std::ostream& os,
const iterator_t& begin,
const iterator_t& end) {
99 __xtd_console_print_container(os, begin, end);
103template<
typename type_t,
size_t size_t>
104inline std::ostream& operator <<(std::ostream& os,
const std::array<type_t, size_t>& values) {
105 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
108template<
typename type_t,
typename allocator_t = std::allocator < type_t>>
109inline std::ostream& operator <<(std::ostream& os,
const std::deque<type_t, allocator_t>& values) {
110 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
113template<
typename type_t,
typename allocator_t = std::allocator<type_t>>
114inline std::ostream& operator <<(std::ostream& os,
const std::forward_list<type_t, allocator_t>& values) {
115 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
118template<
typename type_t>
119inline std::ostream& operator <<(std::ostream& os,
const std::initializer_list<type_t>& values) {
120 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
123template<
typename type_t,
typename allocator_t = std::allocator<type_t>>
124inline std::ostream& operator <<(std::ostream& os,
const std::list<type_t, allocator_t>& values) {
125 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
128template<
typename type_t>
129inline std::ostream& operator <<(std::ostream& os,
const std::valarray<type_t>& values) {
130 return __xtd_console_print_sequence_container(os, std::begin(values), std::end(values));
133template<
typename type_t,
typename allocator_t = std::allocator<type_t>>
134inline std::ostream& operator <<(std::ostream& os,
const std::vector<type_t, allocator_t>& values) {
135 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
138template<
typename iterator_t>
139inline std::ostream& __xtd_console_print_associative_container(std::ostream& os,
const iterator_t& begin,
const iterator_t& end) {
141 __xtd_console_print_container(os, begin, end);
145template<
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>>>
146inline std::ostream& operator <<(std::ostream& os,
const std::map < key_t, value_t, compare_t, allocator_t >& values) {
147 return __xtd_console_print_associative_container(os, values.begin(), values.end());
150template<
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>>>
151inline std::ostream& operator <<(std::ostream& os,
const std::multimap < key_t, value_t, compare_t, allocator_t >& values) {
152 return __xtd_console_print_associative_container(os, values.begin(), values.end());
155template<
typename key_t,
typename compare_t = std::less <key_t>,
typename allocator_t = std::allocator<key_t>>
156inline std::ostream& operator <<(std::ostream& os,
const std::multiset < key_t, compare_t, allocator_t >& values) {
157 return __xtd_console_print_associative_container(os, values.begin(), values.end());
160template <
class key_t,
typename compare_t = std::less < key_t>,
typename allocator_t = std::allocator<key_t >>
161inline std::ostream& operator <<(std::ostream& os,
const std::set < key_t, compare_t, allocator_t >& values) {
162 return __xtd_console_print_associative_container(os, values.begin(), values.end());
165template <
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 >>>
166inline std::ostream& operator <<(std::ostream& os,
const std::unordered_map < key_t, value_t, pred_t, allocator_t >& values) {
167 return __xtd_console_print_associative_container(os, values.begin(), values.end());
170template <
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 >>>
171inline std::ostream& operator <<(std::ostream& os,
const std::unordered_multimap < key_t, value_t, pred_t, allocator_t >& values) {
172 return __xtd_console_print_associative_container(os, values.begin(), values.end());
175template <
class key_t,
typename pred_t = std::equal_to < key_t>,
typename allocator_t = std::allocator<key_t >>
176std::ostream& operator <<(std::ostream& os,
const std::unordered_multiset < key_t, pred_t, allocator_t >& values) {
177 return __xtd_console_print_associative_container(os, values.begin(), values.end());
180template <
class key_t,
typename pred_t = std::equal_to < key_t>,
typename allocator_t = std::allocator<key_t >>
181inline std::ostream& operator <<(std::ostream& os,
const std::unordered_set < key_t, pred_t, allocator_t >& values) {
182 return __xtd_console_print_associative_container(os, values.begin(), values.end());
185inline std::ostream& operator <<(std::ostream& os,
const std::error_category& value) {
186 return os <<
"(" <<
value.name() <<
")";
189inline std::ostream& operator <<(std::ostream& os,
const std::error_code& value) {
190 return os <<
"(value = " <<
value.value() <<
"category= " <<
value.category().name() <<
")";
195 template<
typename type_t>
198auto operator << (std::ostream& os,
const xtd::iformatable& value) -> std::ostream&;
199template<
typename type_t>
201 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
@ value
Represnets the constant operator precedence (42).
Definition operator_precedence.hpp:30
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.