24#ifndef MYSQL_STRCONV_FORMATS_RESOLVE_FORMAT_H
25#define MYSQL_STRCONV_FORMATS_RESOLVE_FORMAT_H
44template <
class Format_t,
class Object_t>
46 requires(Format_t
format, Object_t object) {
51template <
class Format_t>
55template <
class Format_t,
class Object_t>
57 std::declval<Format_t>(), std::declval<Object_t>()));
60template <
template <
class,
class>
class Can_invoke_t,
class Format_t,
66template <
template <
class,
class>
class Can_invoke_t,
class Format_t,
97template <
template <
class,
class>
class Can_invoke_t,
class Object_t,
100 const Object_t &
object [[maybe_unused]]) {
104template <
template <
class,
class>
class Can_invoke_t,
class Object_t,
106 requires Has_impl<Can_invoke_t, Format_t, Object_t>
108 const Object_t &
object [[maybe_unused]]) {
112template <
template <
class,
class>
class Can_invoke_t,
class Object_t,
114 requires(!Has_impl<Can_invoke_t, Format_t, Object_t> &&
115 Has_default_impl<Can_invoke_t, Format_t, Object_t>)
117 const Object_t &
object) {
121template <
template <
class,
class>
class Can_invoke_t,
class Object_t,
123 requires(!Has_impl<Can_invoke_t, Format_t, Object_t> &&
124 !Has_default_impl<Can_invoke_t, Format_t, Object_t> &&
125 Has_parent_format<Format_t>)
127 const Object_t &
object) {
128 return do_resolve_format<Can_invoke_t>(
format.parent(),
object);
132template <
template <
class,
class>
class Can_invoke_t,
class Format_t,
135 std::declval<Format_t>(), std::declval<Object_t>()));
163 template <
class,
class>
class Can_invoke_t,
class Object_t,
167 constexpr bool can_resolve = !std::same_as<Return_t, void>;
168 if constexpr (can_resolve) {
169 return do_resolve_format<Can_invoke_t>(
format,
object);
174#define RESOLVE_FORMAT_ERROR_MESSAGE(TOFROM, PROTOTYPE_ARGS) \
175 "No `mysql::strconv::" TOFROM \
176 "_string_impl` for `Format_t` and " \
177 "`Object_t`, because " \
178 "(1) There is no direct implementation defined with the prototype " \
179 "`mysql::strconv::" TOFROM "_string_impl(const Format_t &, " PROTOTYPE_ARGS \
180 ") (or there are more than one, ambiguously); and " \
181 "(2) there is no default format or no implementation for the " \
182 "default format, i.e., either " \
183 "`get_default_format(const Format_t &, const Object_t &)` " \
184 "is not defined or `mysql::strconv::" TOFROM \
185 "_string_impl(const /*default format*/ &, " PROTOTYPE_ARGS \
186 ")` is not defined (or is defined more than once, ambiguously); and " \
187 "(3) there is no parent format or no implementation for the parent " \
188 "format, i.e., either `Format_t::parent()` is not defined or " \
189 "(1), (2), (3) fail also when replacing `Format_t` by " \
190 "`decltype(Format_t::parent())`. " \
191 "If you believe you have implemented the necessary functions, maybe " \
192 "there are mistakes in their prototypes; to debug this, double-check " \
193 "the namespace, `const` and `&` qualifiers, and/or try to invoke `" TOFROM \
194 "_string_impl` directly and check the compilation error."
202 "to",
"Is_string_target auto &, const Object_t &"));
212#undef RESOLVE_FORMAT_ERROR_MESSAGE
True if <Format_t, Object_t> has a default format and Func_t::call is defined for <Default_format_typ...
Definition: resolve_format.h:68
True if Func_t::call(Format_t, Object_t) is defined.
Definition: resolve_format.h:62
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
Definition: gtid_binary_format_conv.h:252
decltype(get_default_format(std::declval< Format_t >(), std::declval< Object_t >())) Default_format_type
The type of the default format for <Format_t, Object_t>.
Definition: resolve_format.h:57
constexpr void do_resolve_format(const Format_t &format, const Object_t &object)
Return the format to pass to the implementation function, given the format and object type passed by ...
Definition: resolve_format.h:99
decltype(do_resolve_format< Can_invoke_t >(std::declval< Format_t >(), std::declval< Object_t >())) Resolved_format_type
The return type of do_resolve_format.
Definition: resolve_format.h:135
constexpr auto resolve_format(const Format_t &format, const Object_t &object)
Return the format to pass to the implementation function, given the format and object type passed by ...
Definition: resolve_format.h:165
Conversion_direction
Definition: resolve_format.h:138
auto get_default_format(const Binary_format &, const Object_t &)
Definition: gtid_binary_format.h:114
decltype(call_function()) Return_t
Definition: call_and_catch.h:80