di 0.1.0
Loading...
Searching...
No Matches
string.h
Go to the documentation of this file.
1#pragma once
2
10
11namespace di::fmt {
12template<concepts::detail::ConstantString T, concepts::Encoding Enc>
14 bool debug) {
15 return parse<detail::StringFormat>(parse_context.current_format_string()) % [=](detail::StringFormat format) {
16 return [=](concepts::FormatContext auto& context, T const& value) -> Result<void> {
17 auto width = format.width.transform(&detail::Width::value);
18 auto precision = format.precision.transform(&detail::Precision::value);
19 auto do_debug = format.type.has_value() ? format.type == detail::StringType::Debug : debug;
20 return detail::format_string_view_to(context, format.fill_and_align, width, precision, do_debug,
21 value.view());
22 };
23 };
24}
25
26namespace detail {
27 template<typename T>
28 concept ToStringFormattable = requires(T const& v) {
29 { v.to_string() } -> concepts::detail::ConstantString;
30 };
31}
32
33template<detail::ToStringFormattable T, concepts::Encoding Enc>
35 bool debug) {
36 return di::fmt::formatter<container::string::StringViewImpl<Enc>, Enc>(parse_context, debug) %
38 return [=](concepts::FormatContext auto& context, T const& a) {
39 return formatter(context, a.to_string().view());
40 };
41 };
42}
43
44template<concepts::Encoding Enc, concepts::Encoding OtherEnc>
46 FormatParseContext<OtherEnc>& parse_context, bool debug) {
47 return di::fmt::formatter<container::string::StringViewImpl<Enc>, OtherEnc>(parse_context, debug) %
49 return [=](concepts::FormatContext auto& context, container::PathViewImpl<Enc> a) {
50 return formatter(context, a.data());
51 };
52 };
53}
54
55template<concepts::detail::MutableString T, concepts::Encoding Enc>
57 FormatParseContext<Enc>& parse_context, bool debug) {
60 return [=](concepts::FormatContext auto& context, container::PathImpl<T> const& a) {
61 return formatter(context, a.data());
62 };
63 };
64}
65}
Definition path_impl.h:14
Definition path_view_impl.h:22
Definition format_parse_context.h:14
constexpr auto current_format_string() const -> View
Definition format_parse_context.h:191
Definition operations.h:34
Definition format_context.h:9
Definition bounded_format_context.h:7
constexpr auto format
Definition format.h:7
constexpr auto formatter(FormatParseContext< Enc > &parse_context, bool debug=false)
Definition formatter.h:27
di::meta::Decay< decltype(T)> Tag
Definition tag_invoke.h:28
Expected< T, Error > Result
Definition result.h:8
constexpr tag_invoke_detail::TagInvokeFn tag_invoke
Definition tag_invoke.h:22
constexpr auto parse
Definition parse.h:23
Definition in_place_type.h:5