@@ -95,78 +95,3 @@ struct fmt::formatter<boost::system::error_code> {
95
95
return std::copy (std::begin (message), std::end (message), ctx.out ());
96
96
}
97
97
};
98
-
99
- // Remove after it will be added to libp2p (will be happened compilation error)
100
- template <typename T>
101
- struct fmt ::formatter<outcome::success_type<T>> {
102
- // Parses format specifications. Must be empty
103
- constexpr auto parse (format_parse_context &ctx) -> decltype(ctx.begin()) {
104
- // Parse the presentation format and store it in the formatter:
105
- auto it = ctx.begin (), end = ctx.end ();
106
-
107
- // Check if reached the end of the range:
108
- if (it != end && *it != ' }' ) {
109
- throw format_error (" invalid format" );
110
- }
111
-
112
- // Return an iterator past the end of the parsed range:
113
- return it;
114
- }
115
-
116
- // Formats the success<non_void_type>
117
- template <typename OutputIt>
118
- typename std::enable_if_t <not std::is_void_v<T>, OutputIt> format_impl (
119
- OutputIt out, const outcome::success_type<T> &success) const {
120
- return fmt::format_to (out, " {}" , success.value ());
121
- }
122
-
123
- // Formats the success<void>
124
- template <typename OutputIt>
125
- typename std::enable_if_t <std::is_void_v<T>, OutputIt> format_impl (
126
- OutputIt out, const outcome::success_type<void > &) const {
127
- static constexpr string_view message (" <success>" );
128
- return std::copy (std::begin (message), std::end (message), out);
129
- }
130
-
131
- // Formats the success<T>
132
- template <typename FormatContext>
133
- auto format (const outcome::success_type<T> &success, FormatContext &ctx) const
134
- -> decltype(ctx.out()) {
135
- return format_impl (ctx.out (), success);
136
- }
137
- };
138
-
139
- template <typename Result, typename Failure>
140
- struct fmt ::formatter<outcome::result<Result, Failure>> {
141
- // Parses format specifications. Must be empty
142
- constexpr auto parse (format_parse_context &ctx) -> decltype(ctx.begin()) {
143
- // Parse the presentation format and store it in the formatter:
144
- auto it = ctx.begin (), end = ctx.end ();
145
-
146
- // Check if reached the end of the range:
147
- if (it != end && *it != ' }' ) {
148
- throw format_error (" invalid format" );
149
- }
150
-
151
- // Return an iterator past the end of the parsed range:
152
- return it;
153
- }
154
-
155
- // Formats the outcome result
156
- template <typename FormatContext>
157
- auto format (const outcome::result<Result, Failure> &res,
158
- FormatContext &ctx) const -> decltype(ctx.out()) {
159
- // ctx.out() is an output iterator to write to.
160
-
161
- if (res.has_value ()) {
162
- if constexpr (not std::is_void_v<Result>) {
163
- return fmt::format_to (ctx.out (), " {}" , res.value ());
164
- } else {
165
- static constexpr string_view message (" <success>" );
166
- return std::copy (std::begin (message), std::end (message), ctx.out ());
167
- }
168
- } else {
169
- return fmt::format_to (ctx.out (), " {}" , res.error ());
170
- }
171
- }
172
- };
0 commit comments