xtd 1.0.0
Loading...
Searching...
No Matches
to_string_.hpp
Go to the documentation of this file.
1
4#pragma once
6#if !defined(__XTD_TO_STRING_INTERNAL__)
7#error "Do not include this file: Internal use only. Include <xtd/to_string> or <xtd/to_string.hpp> instead."
8#endif
10
11//#include "globalization/culture_info.hpp"
12#include "stream_insertable.hpp"
13#include "to_string.hpp"
14
16template<xtd::iterable range_t>
17[[nodiscard]] auto __xtd_iterable_to_string(const range_t& values, const xtd::string& fmt, const std::locale& loc) -> std::string;
18
19template<typename value_t>
20[[nodiscard]] inline auto xtd::to_string(const value_t& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
21 if constexpr(std::is_polymorphic_v<value_t>) return __to_string_polymorphic(value, fmt, loc);
22 else if constexpr(std::is_enum_v<value_t>) return __enum_formatter<char>(fmt, value, loc);
23 else if constexpr(xtd::iterable<value_t> && !std::is_same_v<value_t, xtd::string>) return __xtd_iterable_to_string(value, fmt, loc);
24 else if constexpr(xtd::stream_insertable<value_t>) {
25 auto ss = std::stringstream {};
26 ss << value;
27 return ss.str();
29}
30
31template<class value_t>
32requires (requires (const xtd::raw_type<value_t>& value, const xtd::string& fmt) {{value.to_string(fmt)} -> xtd::textual;})
33[[nodiscard]] inline auto xtd::to_string(const value_t& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
34 return value.to_string(fmt);
35}
36
37template<class value_t>
38requires (!requires (const xtd::raw_type<value_t>& value, const xtd::string& fmt) {{value.to_string(fmt)} -> xtd::textual;} && requires (const xtd::raw_type<value_t>& value) {{value.to_string()} -> xtd::textual;})
39[[nodiscard]] inline auto xtd::to_string(const value_t& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
40 return value.to_string();
41}
42
43template<>
44[[nodiscard]] inline auto xtd::to_string(const bool& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
45 return __boolean_formatter(fmt.chars(), value, loc);
46}
47
48template<>
49[[nodiscard]] inline auto xtd::to_string(const sbyte& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
50 return __numeric_formatter(fmt.chars(), value, loc);
51}
52
53template<>
54[[nodiscard]] inline auto xtd::to_string(const char& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
55 return __character_formatter(fmt.chars(), value, loc);
56}
57
58template<>
59[[nodiscard]] inline auto xtd::to_string(const unsigned char& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
60 return __numeric_formatter(fmt.chars(), value, loc);
61}
62
63template<>
64[[nodiscard]] inline auto xtd::to_string(const short& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
65 return __numeric_formatter(fmt.chars(), value, loc);
66}
67
68template<>
69[[nodiscard]] inline auto xtd::to_string(const unsigned short& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
70 return __numeric_formatter(fmt.chars(), value, loc);
71}
72
73template<>
74[[nodiscard]] inline auto xtd::to_string(const int& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
75 return __numeric_formatter(fmt.chars(), value, loc);
76}
77
78template<>
79[[nodiscard]] inline auto xtd::to_string(const unsigned int& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
80 return __numeric_formatter(fmt.chars(), value, loc);
81}
82
83template<>
84[[nodiscard]] inline auto xtd::to_string(const long& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
85 return __numeric_formatter(fmt.chars(), value, loc);
86}
87
88template<>
89[[nodiscard]] inline auto xtd::to_string(const unsigned long& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
90 return __numeric_formatter(fmt.chars(), value, loc);
91}
92
93template<>
94[[nodiscard]] inline auto xtd::to_string(const long long& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
95 return __numeric_formatter(fmt.chars(), value, loc);
96}
97
98template<>
99[[nodiscard]] inline auto xtd::to_string(const unsigned long long& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
100 return __numeric_formatter(fmt.chars(), value, loc);
101}
102
103template<>
104[[nodiscard]] inline auto xtd::to_string(const float& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
105 return __floating_point_formatter(fmt.chars(), value, loc);
106}
107
108template<>
109[[nodiscard]] inline auto xtd::to_string(const double& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
110 return __floating_point_formatter(fmt.chars(), value, loc);
111}
112
113template<>
114[[nodiscard]] inline auto xtd::to_string(const long double& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
115 return __floating_point_formatter(fmt.chars(), value, loc);
116}
117
118template<>
119[[nodiscard]] inline auto xtd::to_string(const std::chrono::system_clock::time_point& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
120 return __date_time_formatter(fmt.chars(), std::chrono::system_clock::to_time_t(value), std::chrono::duration_cast<std::chrono::nanoseconds>(value.time_since_epoch()).count() % 1000000000, loc);
121}
122
123template<>
124[[nodiscard]] inline auto xtd::to_string(const std::tm& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
125 return __date_time_formatter(fmt.chars(), value, 0, loc);
126}
127
128template<typename type_t, typename period_t>
129[[nodiscard]] inline auto xtd::to_string(const std::chrono::duration<type_t, period_t>& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
130 return __duration_formatter(fmt.chars(), value, loc);
131}
132
133template<>
134[[nodiscard]] inline auto xtd::to_string(const char8& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
135 return __character_formatter(fmt.chars(), value, loc);
136}
137
138template<>
139[[nodiscard]] inline auto xtd::to_string(const char16& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
140 return __character_formatter(fmt.chars(), value, loc);
141}
142
143template<>
144[[nodiscard]] inline auto xtd::to_string(const char32& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
145 return __character_formatter(fmt.chars(), value, loc);
146}
147
148template<>
149[[nodiscard]] inline auto xtd::to_string(const wchar& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
150 return __character_formatter(fmt.chars(), value, loc);
151}
152
153template<typename value_t>
154[[nodiscard]] inline auto xtd::to_string(const value_t& value, const xtd::string& fmt) -> xtd::string {
155 return to_string(value, fmt, std::locale());
156}
157
158[[nodiscard]] inline auto xtd::to_string(const char* value, const xtd::string& fmt) -> xtd::string {
159 return to_string(value, fmt, std::locale());
160}
161
162template<>
163[[nodiscard]] inline auto xtd::to_string(const std::partial_ordering& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
164 if (value == std::partial_ordering::less) return "less";
165 if (value == std::partial_ordering::greater) return "greater";
166 return "equivalent";
167}
168
169template<>
170[[nodiscard]] inline auto xtd::to_string(const std::strong_ordering& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
171 if (value == std::strong_ordering::less) return "less";
172 if (value == std::strong_ordering::greater) return "greater";
173 return "equivalent";
174}
175
176template<>
177[[nodiscard]] inline auto xtd::to_string(const std::weak_ordering& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
178 if (value == std::weak_ordering::less) return "less";
179 if (value == std::weak_ordering::greater) return "greater";
180 return "equivalent";
181}
182
183template<typename value_t>
184[[nodiscard]] inline auto xtd::to_string(const value_t* value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
185 if (!value) return "(null)";
186 return __numeric_formatter(fmt.chars(), reinterpret_cast<intptr>(value), loc);
187}
188
189template<typename value_t>
190[[nodiscard]] inline auto xtd::to_string(value_t* const value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
191 if (!value) return "(null)";
192 return __numeric_formatter(fmt.chars(), reinterpret_cast<intptr>(value), loc);
193}
194
195template<typename type_t>
196[[nodiscard]] inline auto xtd::to_string(const std::shared_ptr<type_t>& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
197 if (!value) return "(null)";
198 return __numeric_formatter(fmt.chars(), reinterpret_cast<intptr>(value.get()), loc);
199}
200
201template<typename type_t>
202[[nodiscard]] inline auto xtd::to_string(const std::unique_ptr<type_t>& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
203 if (!value) return "(null)";
204 return __numeric_formatter(fmt.chars(), reinterpret_cast<intptr>(value.get()), loc);
205}
206
207template<>
208[[nodiscard]] inline auto xtd::to_string(const xtd::any& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
209 auto iterator = __any_stringer__.find(std::type_index(value.type()));
210 return iterator != __any_stringer__.cend() ? xtd::to_string(iterator->second(value), fmt, loc) : "(unregistered)";
211}
212
213template<typename type_t>
214[[nodiscard]] inline auto xtd::to_string(const std::optional<type_t>& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
215 return !value.has_value() ? "(null)" : std::string {"("} + to_string(value.value(), fmt, loc).chars() + std::string {")"};
216}
217
218template<>
219[[nodiscard]] inline auto xtd::to_string(const std::nullopt_t& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
220 return "(null)";
221}
222
223template<>
224[[nodiscard]] inline auto xtd::to_string(const std::nullptr_t&, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
225 return "null";
226}
227
228template<typename type1_t, typename type2_t>
229[[nodiscard]] inline auto xtd::to_string(const std::pair<type1_t, type2_t>& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
230 return std::string {"("} + to_string(value.first, fmt, loc).chars() + std::string {", "} + to_string(value.second, fmt, loc).chars() + std::string {")"};
231}
232
233template<typename type_t, unsigned n_t, unsigned last_t>
234[[nodiscard]] inline auto xtd::__xtd_tuple_stringer<type_t, n_t, last_t>::to_string(const std::string& str, const type_t& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
235 return __xtd_tuple_stringer < type_t, n_t + 1, last_t >::to_string(str + xtd::to_string(std::get<n_t>(value), fmt, loc).chars() + ", ", value, fmt, loc);
236}
237
238template<typename type_t, unsigned n_t>
239[[nodiscard]] inline auto xtd::__xtd_tuple_stringer<type_t, n_t, n_t>::to_string(const std::string& str, const type_t& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
240 return str + xtd::to_string(std::get<n_t>(value), fmt, loc).chars();
241}
242
243template<typename ...types_t>
244[[nodiscard]] inline auto xtd::to_string(const std::tuple<types_t ...>& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
245 return __xtd_tuple_stringer < std::tuple<types_t ...>, 0, sizeof...(types_t) - 1 >::to_string(std::string {"("}, value, fmt, loc) + ")";
246}
247
248template<typename iterator_t>
249[[nodiscard]] inline auto __xtd_iterator_to_string(const std::string& str, iterator_t iterator, const iterator_t& begin, const iterator_t& end, const xtd::string& fmt, const std::locale& loc) -> std::string {
250 if (iterator == end) return str;
251 auto new_str = str + (iterator == begin ? std::string {} : std::string {", "}) + xtd::to_string(*iterator, fmt, loc).chars();
252 return __xtd_iterator_to_string(new_str, ++iterator, begin, end, fmt, loc);
253}
254
255template<typename iterator_t>
256[[nodiscard]] inline auto __xtd_sequence_container_to_string(const iterator_t& begin, const iterator_t& end, const xtd::string& fmt, const std::locale& loc) -> std::string {
257 return __xtd_iterator_to_string("[", begin, begin, end, fmt, loc) + "]";
258}
259
260template<xtd::iterable iterable_t>
261[[nodiscard]] inline auto __xtd_iterable_to_string(const iterable_t& values, const xtd::string& fmt, const std::locale& loc) -> std::string {
262 std::ostringstream oss;
263 oss.imbue(loc);
264 oss << "[";
265 auto first = true;
266 auto& mutable_values = const_cast<iterable_t&>(values);
267 for (const auto value : mutable_values) {
268 if (!first) oss << ", ";
269 first = false;
270 oss << xtd::to_string(value, fmt, loc);
271 }
272 oss << "]";
273 return oss.str();
274}
275
276template<typename type_t, xtd::usize size>
277[[nodiscard]] inline auto xtd::to_string(const std::array<type_t, size>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
278 return __xtd_sequence_container_to_string(values.begin(), values.end(), fmt, loc);
279}
280
281template<xtd::usize size>
282[[nodiscard]] inline auto xtd::to_string(const std::bitset<size>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
283 auto result = xtd::string {"["};
284 for (auto index = xtd::usize {0}; index < values.length(); ++index)
285 result += (index ? ", " : "") + to_string(static_cast<bool>(values[index]), fmt, loc);
286 return result + "]";
287}
288
289template<typename type_t, typename allocator_t>
290[[nodiscard]] inline auto xtd::to_string(const std::deque<type_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
291 return __xtd_sequence_container_to_string(values.begin(), values.end(), fmt, loc);
292}
293
294template<typename type_t, typename allocator_t>
295[[nodiscard]] inline auto xtd::to_string(const std::forward_list<type_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
296 return __xtd_sequence_container_to_string(values.begin(), values.end(), fmt, loc);
297}
298
299template<typename type_t>
300[[nodiscard]] inline auto xtd::to_string(const std::initializer_list<type_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
301 return __xtd_sequence_container_to_string(values.begin(), values.end(), fmt, loc);
302}
303
304template<typename type_t, typename allocator_t>
305[[nodiscard]] inline auto xtd::to_string(const std::list<type_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
306 return __xtd_sequence_container_to_string(values.begin(), values.end(), fmt, loc);
307}
308
309template<typename type_t, typename container_t>
310[[nodiscard]] inline auto xtd::to_string(const std::queue<type_t, container_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
311 struct accessor : public std::queue<type_t> {static auto get() {return &accessor::c;}};
312 const auto& underlying_items = values.*accessor::get();
313 return __xtd_sequence_container_to_string(underlying_items.begin(), underlying_items.end(), fmt, loc);
314}
315
316template<typename type_t, typename container_t>
317[[nodiscard]] inline auto xtd::to_string(const std::priority_queue<type_t, container_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
318 struct std_priority_queue : public std::queue<type_t> {
319 std_priority_queue(const std::priority_queue<type_t>& queue) : ptr {reinterpret_cast<const std_priority_queue*>(&queue)} {}
320 auto begin() const {return ptr->c.begin();}
321 auto end() const {return ptr->c.end();}
322 const std_priority_queue* ptr;
323 };
324 auto items = std_priority_queue {values};
325 return __xtd_sequence_container_to_string(items.begin(), items.end(), fmt, loc);
326}
327
328template<typename type_t, typename container_t>
329[[nodiscard]] inline auto xtd::to_string(const std::stack<type_t, container_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
330 struct accessor : public std::stack<type_t> {static auto get() {return &accessor::c;}};
331 const auto& underlying_items = values.*accessor::get();
332 return __xtd_sequence_container_to_string(underlying_items.rbegin(), underlying_items.rend(), fmt, loc);
333}
334
335template<typename type_t>
336[[nodiscard]] inline auto xtd::to_string(const std::valarray<type_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
337 return __xtd_sequence_container_to_string(std::begin(values), std::end(values), fmt, loc);
338}
339
340template<typename type_t, typename allocator_t>
341[[nodiscard]] inline auto xtd::to_string(const std::vector<type_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
342 return __xtd_sequence_container_to_string(values.begin(), values.end(), fmt, loc);
343}
344
345template<typename iterator_t>
346[[nodiscard]] inline auto __xtd_associative_container_to_string(const iterator_t& begin, const iterator_t& end, const xtd::string& fmt, const std::locale& loc) -> std::string {
347 return __xtd_iterator_to_string("{", begin, begin, end, fmt, loc) + "}";
348}
349
350template<typename key_t, typename value_t, typename compare_t, typename allocator_t>
351[[nodiscard]] inline auto xtd::to_string(const std::map<key_t, value_t, compare_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
352 return __xtd_associative_container_to_string(values.begin(), values.end(), fmt, loc);
353}
354
355template<typename key_t, typename value_t, typename compare_t, typename allocator_t>
356[[nodiscard]] inline auto xtd::to_string(const std::multimap<key_t, value_t, compare_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
357 return __xtd_associative_container_to_string(values.begin(), values.end(), fmt, loc);
358}
359
360template<typename key_t, typename compare_t, typename allocator_t>
361[[nodiscard]] inline auto xtd::to_string(const std::multiset<key_t, compare_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
362 return __xtd_associative_container_to_string(values.begin(), values.end(), fmt, loc);
363}
364
365template<typename key_t, typename compare_t, typename allocator_t>
366[[nodiscard]] inline auto xtd::to_string(const std::set<key_t, compare_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
367 return __xtd_associative_container_to_string(values.begin(), values.end(), fmt, loc);
368}
369
370template<typename key_t, typename value_t, typename compare_t, typename allocator_t>
371[[nodiscard]] inline auto xtd::to_string(const std::unordered_map<key_t, value_t, compare_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
372 return __xtd_associative_container_to_string(values.begin(), values.end(), fmt, loc);
373}
374
375template<typename key_t, typename value_t, typename compare_t, typename allocator_t>
376[[nodiscard]] inline auto xtd::to_string(const std::unordered_multimap<key_t, value_t, compare_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
377 return __xtd_associative_container_to_string(values.begin(), values.end(), fmt, loc);
378}
379
380template<typename key_t, typename compare_t, typename allocator_t>
381[[nodiscard]] inline auto xtd::to_string(const std::unordered_multiset<key_t, compare_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
382 return __xtd_associative_container_to_string(values.begin(), values.end(), fmt, loc);
383}
384
385template<typename key_t, typename compare_t, typename allocator_t>
386[[nodiscard]] inline auto xtd::to_string(const std::unordered_set<key_t, compare_t, allocator_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
387 return __xtd_associative_container_to_string(values.begin(), values.end(), fmt, loc);
388}
389
390template<typename ...args_t>
391[[nodiscard]] inline auto xtd::to_string(const std::variant<args_t...>& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
392 if (value.valueless_by_exception()) return "(valueless_by_exception)";
393 return std::visit([&](auto && t){return xtd::to_string(t, fmt, loc);}, value);
394}
395
396template<typename type_t>
397[[nodiscard]] inline auto xtd::to_string(type_t value, const std::initializer_list<std::pair<type_t, xtd::string>>& il) -> xtd::string {
398 std::map<type_t, xtd::string, std::greater<type_t>> values;
399 for (const auto& item : il) values[item.first] = item.second;
400 return to_string(value, values);
401}
402
403template<>
404inline auto xtd::to_string(const std::filesystem::path& value, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
405 return to_string(value.string(), fmt, loc);
406}
407
408template<typename type_t>
409[[nodiscard]] inline auto xtd::to_string(const xtd::collections::generic::ienumerable<type_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
410 return __xtd_sequence_container_to_string(values.begin(), values.end(), fmt, loc);
411}
412
413template<typename type_t>
414[[nodiscard]] inline auto xtd::to_string(const xtd::collections::generic::helpers::raw_array<type_t>& values, const xtd::string& fmt, const std::locale& loc) -> xtd::string {
415 return __xtd_sequence_container_to_string(values.begin(), values.end(), fmt, loc);
416}
417
418template<typename type_t, typename string_t>
419[[nodiscard]] inline auto xtd::to_string(type_t value, const std::map<type_t, string_t, std::greater<type_t>>& values) -> string_t {
420 auto it = values.find(value);
421 if (it != values.end()) return it->second;
422 string_t result;
423 long long rest = static_cast<long long>(value);
424 for (const auto& item : values) {
425 if (static_cast<long long>(item.first) != 0 && (rest & static_cast<long long>(item.first)) == static_cast<long long>(item.first)) {
426 if (!result.empty()) result = string_t {',', ' '} + result;
427 result = item.second + result;
428 rest -= static_cast<long long>(item.first);
429 }
430 }
431 if (!result.empty()) return result;
432 return to_string(static_cast<long long>(value), string_t {'G'}, std::locale());
433}
434
435template<typename type_t, typename string_t>
436[[nodiscard]] inline auto xtd::to_string(type_t value, const std::map<type_t, string_t>& values) -> string_t {
437 std::map<type_t, string_t, std::greater<type_t>> descending_values;
438 for (const auto& item : values) descending_values[item.first] = item.second;
439 return to_string(value, descending_values);
440}
441
442template<typename char_t, typename value_t>
443[[nodiscard]] inline auto __string_formatter(const std::basic_string<char_t>& fmt, value_t value, const std::locale& loc) -> std::basic_string<char_t> {
444 return __format_stringer<char_t>(value);
445}
446
447template<>
448[[nodiscard]] inline auto __format_stringer<char, bool&>(bool& value) -> std::string {
449 return xtd::to_string(value, "G", std::locale());
450}
451
452template<>
453[[nodiscard]] inline auto __format_stringer<char, xtd::sbyte&>(xtd::sbyte& value) -> std::string {
454 return xtd::to_string(value, "G", std::locale());
455}
456
457template<>
458[[nodiscard]] inline auto __format_stringer<char, const unsigned char&>(const unsigned char& value) -> std::string {
459 return xtd::to_string(value, "G", std::locale());
460}
461
462template<>
463[[nodiscard]] inline auto __format_stringer<char, unsigned char&>(unsigned char& value) -> std::string {
464 return xtd::to_string(value, "G", std::locale());
465}
466
467template<>
468[[nodiscard]] inline auto __format_stringer<char, short&>(short& value) -> std::string {
469 return xtd::to_string(value, "G", std::locale());
470}
471
472template<>
473[[nodiscard]] inline auto __format_stringer<char, unsigned short&>(unsigned short& value) -> std::string {
474 return xtd::to_string(value, "G", std::locale());
475}
476
477template<>
478[[nodiscard]] inline auto __format_stringer<char, int&>(int& value) -> std::string {
479 return xtd::to_string(value, "G", std::locale());
480}
481
482template<>
483[[nodiscard]] inline auto __format_stringer<char, unsigned int&>(unsigned int& value) -> std::string {
484 return xtd::to_string(value, "G", std::locale());
485}
486
487template<>
488[[nodiscard]] inline auto __format_stringer<char, long&>(long& value) -> std::string {
489 return xtd::to_string(value, "G", std::locale());
490}
491
492template<>
493[[nodiscard]] inline auto __format_stringer<char, unsigned long&>(unsigned long& value) -> std::string {
494 return xtd::to_string(value, "G", std::locale());
495}
496
497template<>
498[[nodiscard]] inline auto __format_stringer<char, long long&>(long long& value) -> std::string {
499 return xtd::to_string(value, "G", std::locale());
500}
501
502template<>
503[[nodiscard]] inline auto __format_stringer<char, unsigned long long&>(unsigned long long& value) -> std::string {
504 return xtd::to_string(value, "G", std::locale());
505}
506
507template<>
508[[nodiscard]] inline auto __format_stringer<char, float&>(float& value) -> std::string {
509 return xtd::to_string(value, "G", std::locale());
510}
511
512template<>
513[[nodiscard]] inline auto __format_stringer<char, double&>(double& value) -> std::string {
514 return xtd::to_string(value, "G", std::locale());
515}
516
517template<>
518[[nodiscard]] inline auto __format_stringer<char, long double&>(long double& value) -> std::string {
519 return xtd::to_string(value, "G", std::locale());
520}
521
522template<>
523[[nodiscard]] inline auto __format_stringer<char, std::chrono::system_clock::time_point&>(std::chrono::system_clock::time_point& value) -> std::string {
524 return xtd::to_string(value, "G", std::locale());
525}
526
527template<>
528[[nodiscard]] inline auto __format_stringer<char, std::tm&>(tm& value) -> std::string {
529 return xtd::to_string(value, "G", std::locale());
530}
531
532template<>
533[[nodiscard]] inline auto __format_stringer<char, xtd::wchar&>(xtd::wchar& value) -> std::string {
534 return xtd::to_string(value, "G", std::locale());
535}
536
537template<>
538[[nodiscard]] inline auto __format_stringer<char, xtd::char8&>(xtd::char8& value) -> std::string {
539 return xtd::to_string(value, "G", std::locale());
540}
541
542template<>
543[[nodiscard]] inline auto __format_stringer<char, xtd::char16&>(xtd::char16& value) -> std::string {
544 return xtd::to_string(value, "G", std::locale());
545}
546
547template<>
548[[nodiscard]] inline auto __format_stringer<char, xtd::char32&>(xtd::char32& value) -> std::string {
549 return xtd::to_string(value, "G", std::locale());
550}
551
552template<typename char_t, typename type_t, typename period_t = std::ratio<1>>
553auto operator <<(std::basic_ostream<char_t>& os, const std::chrono::duration<type_t, period_t>& value) -> std::basic_ostream<char_t>& {
554 return os << xtd::to_string(value, std::basic_string<char_t> {'G'}, std::locale());
555}
556
557template < class char_t, typename type_t >
558struct __enum_ostream__<char_t, type_t, std::false_type> {
559 auto to_stream(std::basic_ostream < char_t >& os, const type_t& value) noexcept -> std::basic_ostream<char_t>& {
560 //return os << value;
561 return os << xtd::to_string(value, std::basic_string < char_t > {}, std::locale {});
562 }
563};
auto chars() const noexcept -> const base_type &
Returns a reference to the underlying base type.
Definition basic_string.hpp:357
Internal vector-like container used as a storage backend for xtd collections.
Definition raw_array.hpp:30
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
Definition iterable.hpp:15
Definition stream_insertable.hpp:13
Definition textual.hpp:16
generic::queue< xtd::any_object > queue
Represents a first-in, first-out collection of objects.
Definition queue.hpp:27
@ value
Represnets the constant operator precedence (42).
Definition operator_precedence.hpp:30
@ format
The format is not valid.
Definition exception_case.hpp:51
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
char8_t char8
Represents a 8-bit unicode character.
Definition char8.hpp:26
std::int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.hpp:23
wchar_t wchar
Represents a wide character.
Definition wchar.hpp:24
std::intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
char16_t char16
Represents a 16-bit unicode character.
Definition char16.hpp:26
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
char32_t char32
Represents a 32-bit unicode character.
Definition char32.hpp:23
std::any any
Represents the any alias on std::any.
Definition any.hpp:24
std::remove_cvref_t< value_t > raw_type
Represents a raw type alias equivalent to std::remove_cvref_t<value_t>.
Definition raw_type.hpp:25
const xtd::collections::generic::helpers::wrap_pointer_iterator< pointer > iterator
Represents the iterator of read_only_span value type.
Definition read_only_span.hpp:70
auto first() const -> read_only_span< type_t, count >
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:248
auto begin() const -> const_iterator
Returns an iterator to the beginning.
Definition read_only_span.hpp:185
auto to_string() const noexcept -> xtd::string override
Returns the string representation of this xtd::read_only_span <type_t> object.
Definition read_only_span.hpp:341
auto end() const -> const_iterator
Returns an iterator to the end.
Definition read_only_span.hpp:204
Contains xtd::stream_insertable concept.
Contains xtd::to_string methods.