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 auto operator <<(std::ostream& os,
const std::exception& value) -> std::ostream& {
34 return os <<
"exception: " <<
value.what();
37template<
typename value_t>
39inline auto operator <<(std::ostream& os,
const std::optional<value_t>& value) -> std::ostream& {
40 if (!
value.has_value())
return os <<
"(null)";
41 return os <<
"(" <<
value.value() <<
")";
44template<
typename value_t>
46inline auto operator <<(std::ostream& os,
const std::optional<value_t>&) -> std::ostream& {
47 return os <<
"(unregistered)";
50template<
typename type1_t,
typename type2_t>
52inline auto operator <<(std::ostream& os,
const std::pair<type1_t, type2_t>& value) -> std::ostream& {
53 return os <<
"(" <<
value.first <<
", " <<
value.second <<
")";
56template<
typename type1_t,
typename type2_t>
58inline auto operator <<(std::ostream& os,
const std::pair<type1_t, type2_t>& value) -> std::ostream& {
62template<
typename type_t,
unsigned n_t,
unsigned last_t>
64struct __xtd_console_tuple_printer {
65 static auto print(std::ostream& os,
const type_t& value) ->
void {
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 auto operator <<(std::ostream& os,
const std::tuple<types_t ... >& value) -> std::ostream& {
76 __xtd_console_tuple_printer<std::tuple<types_t...>, 0,
sizeof...(types_t) - 1>::print(os, value);
80template<
typename iterator_t>
82inline auto __xtd_console_print_container(std::ostream& os,
const iterator_t& begin,
const iterator_t& end) ->
void {
83 for (
auto it = begin; it !=
end; ++it) {
84 os << (it !=
begin ?
", " :
"") << *it;
88template<
typename iterator_t>
90inline auto __xtd_console_print_container(std::ostream& os,
const iterator_t& begin,
const iterator_t& end) ->
void {
91 for (
auto it = begin; it !=
end; ++it) {
92 os << (it !=
begin ?
", " :
"") <<
" ";
96template<
typename iterator_t>
97inline auto __xtd_console_print_sequence_container(std::ostream& os,
const iterator_t& begin,
const iterator_t& end) -> std::ostream& {
99 __xtd_console_print_container(os, begin, end);
103template<
typename type_t,
size_t size_t>
104inline auto operator <<(std::ostream& os,
const std::array<type_t, size_t>& values) -> std::ostream& {
105 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
108template<
typename type_t,
typename allocator_t = std::allocator < type_t>>
109inline auto operator <<(std::ostream& os,
const std::deque<type_t, allocator_t>& values) -> std::ostream& {
110 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
113template<
typename type_t,
typename allocator_t = std::allocator<type_t>>
114inline auto operator <<(std::ostream& os,
const std::forward_list<type_t, allocator_t>& values) -> std::ostream& {
115 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
118template<
typename type_t>
119inline auto operator <<(std::ostream& os,
const std::initializer_list<type_t>& values) -> std::ostream& {
120 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
123template<
typename type_t,
typename allocator_t = std::allocator<type_t>>
124inline auto operator <<(std::ostream& os,
const std::list<type_t, allocator_t>& values) -> std::ostream& {
125 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
128template<
typename type_t>
129inline auto operator <<(std::ostream& os,
const std::valarray<type_t>& values) -> std::ostream& {
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 auto operator <<(std::ostream& os,
const std::vector<type_t, allocator_t>& values) -> std::ostream& {
135 return __xtd_console_print_sequence_container(os, values.begin(), values.end());
138template<
typename iterator_t>
139inline auto __xtd_console_print_associative_container(std::ostream& os,
const iterator_t& begin,
const iterator_t& end) -> std::ostream& {
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 auto operator <<(std::ostream& os,
const std::map < key_t, value_t, compare_t, allocator_t >& values) -> std::ostream& {
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 auto operator <<(std::ostream& os,
const std::multimap < key_t, value_t, compare_t, allocator_t >& values) -> std::ostream& {
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 auto operator <<(std::ostream& os,
const std::multiset < key_t, compare_t, allocator_t >& values) -> std::ostream& {
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 auto operator <<(std::ostream& os,
const std::set < key_t, compare_t, allocator_t >& values) -> std::ostream& {
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 auto operator <<(std::ostream& os,
const std::unordered_map < key_t, value_t, pred_t, allocator_t >& values) -> std::ostream& {
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 auto operator <<(std::ostream& os,
const std::unordered_multimap < key_t, value_t, pred_t, allocator_t >& values) -> std::ostream& {
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 >>
176auto operator <<(std::ostream& os,
const std::unordered_multiset < key_t, pred_t, allocator_t >& values) -> std::ostream& {
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 auto operator <<(std::ostream& os,
const std::unordered_set < key_t, pred_t, allocator_t >& values) -> std::ostream& {
182 return __xtd_console_print_associative_container(os, values.begin(), values.end());
185inline auto operator <<(std::ostream& os,
const std::error_category& value) -> std::ostream& {
186 return os <<
"(" <<
value.name() <<
")";
189inline auto operator <<(std::ostream& os,
const std::error_code& value) -> std::ostream& {
190 return os <<
"(value = " <<
value.value() <<
"category= " <<
value.category().name() <<
")";
195 template<
typename type_t>
199auto operator << (std::ostream& os,
const xtd::iformatable& value) -> std::ostream&;
201template<
typename type_t>
203 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
auto begin() const -> const_iterator
Returns an iterator to the beginning.
Definition read_only_span.hpp:186
auto end() const -> const_iterator
Returns an iterator to the end.
Definition read_only_span.hpp:205
auto print(FILE *file, arg_t &&value) -> void
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.