21#include <unordered_map>
22#include <unordered_set>
57namespace welder::inline v0 {
79template <caster_oracle B,
class T, lang L,
class Reg>
80consteval bool bindable();
107 {^^std::vector, 1}, {^^std::list, 1},
108 {^^std::deque, 1}, {^^std::set, 1},
109 {^^std::multiset, 1}, {^^std::unordered_set, 1},
110 {^^std::unordered_multiset, 1},
111 {^^std::map, 2}, {^^std::multimap, 2},
112 {^^std::unordered_map, 2}, {^^std::unordered_multimap, 2},
113 {^^std::optional, 1}, {^^std::shared_ptr, 1},
114 {^^std::unique_ptr, 1}, {^^std::pair, 2},
115 {^^std::array, 1}, {^^std::tuple, 0},
127 if (!std::meta::has_template_arguments(type))
129 const std::meta::info tmpl{std::meta::template_of(type)};
132 return w.values != 0 ?
static_cast<long>(w.values)
134 std::meta::template_arguments_of(type).size());
142template <std::meta::info Type, std::
size_t N>
144 std::array<std::meta::info, N> out{};
146 for (
auto arg : std::meta::template_arguments_of(Type)) {
162 return std::meta::has_template_arguments(type) &&
163 std::meta::template_of(type) == ^^std::expected;
169 return std::meta::template_arguments_of(type)[0];
183 return std::meta::has_template_arguments(type) &&
184 std::meta::template_of(type) == ^^std::span;
190 return std::meta::template_arguments_of(type)[0];
202 return (
bindable<B,
typename [:Args[I]:], L, Reg>() && ...);
217template <caster_oracle B,
class T, lang L,
class Reg>
225 constexpr std::meta::info u{std::meta::dealias(
226 ^^std::remove_cv_t<std::remove_pointer_t<std::remove_cvref_t<T>>>)};
235 if constexpr (values >= 0) {
238 std::make_index_sequence<args.size()>{});
239 }
else if constexpr (B::template has_native_caster<typename [:u:]>) {
264 }
else if constexpr (std::meta::is_union_type(u)) {
274 return Reg::counts_as_registered(u, L);
281consteval bool mentions_union();
286template <
auto Args, std::size_t... I>
302 constexpr std::meta::info u{std::meta::dealias(
303 ^^std::remove_cv_t<std::remove_pointer_t<std::remove_cvref_t<T>>>)};
304 if constexpr (std::meta::is_union_type(u)) {
308 if constexpr (values >= 0) {
311 std::make_index_sequence<args.size()>{});
329template <caster_oracle B,
class T, lang L,
class Reg = welded_registration>
343template <caster_oracle B,
class T, lang L,
class Reg = welded_registration>
351 "welder: this surface names a UNION, and unions do not bind — C++ has "
352 "no way to observe which member is active, so generated accessors "
353 "would read inactive members (undefined behavior). Use std::variant "
354 "instead (converted natively by every rod), or expose safe accessor "
355 "functions; otherwise mark::exclude the member that uses it. To "
356 "hand-register the union with the backend yourself, vouch for it via "
357 "welder::trust_bindable. The offending type is the template argument "
358 "of this assert_bindable<B, T, L> instantiation.");
361 "welder: cannot bind this C++ type to the target language. Weld it with "
362 "[[=welder::weld(...)]], or register a backend type converter for it; "
363 "otherwise mark::exclude the member that uses it. The offending type is "
364 "the template argument of this assert_bindable<B, T, L> instantiation.");
375template <caster_oracle B, std::meta::info Fn, lang L,
class Reg, std::size_t... I>
391template <caster_oracle B, std::meta::info Fn, lang L,
392 class Reg = welded_registration>
397 constexpr std::size_t n{std::meta::parameters_of(Fn).size()};
398 if constexpr (n != 0)
400 if constexpr (!std::meta::is_constructor(Fn)) {
401 using R = [:std::meta::return_type_of(Fn):];
402 if constexpr (!std::is_void_v<R>)
420template <caster_oracle B, std::meta::info Member, lang L,
421 class Reg = welded_registration>
432template <caster_oracle B, std::meta::info Fn, lang L,
433 class Reg = welded_registration>
451template <caster_oracle B, std::meta::info Fn, lang L,
452 class Reg = welded_registration>
455 constexpr std::size_t n{std::meta::parameters_of(Fn).size()};
456 if constexpr (n != 0)
458 std::make_index_sequence<n>{});
468template <caster_oracle B, std::meta::info Fn, std::meta::info Type, lang L,
469 class Reg, std::size_t... I>
474 if constexpr (std::meta::dealias(std::meta::remove_cvref(
475 params[I])) != std::meta::dealias(Type))
495template <caster_oracle B, std::meta::info Fn, std::meta::info Type, lang L,
496 class Reg = welded_registration>
499 constexpr std::size_t n{std::meta::parameters_of(Fn).size()};
500 if constexpr (n != 0)
502 std::make_index_sequence<n>{});
Backend-agnostic selection layer: the reflection predicates and selectors that decide what participat...
The core interface concepts welder's static polymorphism rests on, gathered in one catalogue: the cus...
The one bindability fact a backend must provide: can it natively convert a type without welder regist...
consteval std::meta::info expected_value_arg(std::meta::info type)
The VALUE argument of the std::expected type (its first).
consteval std::array< wrapper_spec, 18 > stl_wrappers()
The element-wise STL-wrapper table welder recurses into.
consteval bool mentions_union()
Forward declaration: mentions_union() recurses like bindable() does.
consteval bool args_mention_union(std::index_sequence< I... >)
Whether every one of a wrapper's value arguments mentions a union.
consteval void assert_params_bindable(std::index_sequence< I... >)
Assert every parameter type of Fn binds.
consteval bool args_bindable(std::index_sequence< I... >)
Whether every one of a wrapper's value arguments (spliced back to types) binds.
consteval void assert_operands(std::index_sequence< I... >)
The parameter walk behind assert_operands_bindable — gate each parameter that is not the anchor type ...
consteval auto param_types()
A function's parameter types, as a static array of reflections.
consteval bool is_span_specialization(std::meta::info type)
Is type a std::span specialization — the non-owning sequence view?
consteval std::meta::info span_element_arg(std::meta::info type)
The ELEMENT argument of the std::span type (its first).
consteval long wrapper_value_count(std::meta::info type)
How many leading arguments of type to recurse if it is a listed wrapper.
consteval bool is_expected_specialization(std::meta::info type)
Is type a std::expected specialization — the fallible-result family?
consteval bool bindable()
Forward declaration: bindable() recurses through a container's element types.
consteval std::array< std::meta::info, N > leading_args()
The first N template arguments of Type, as a splice-ready static array.
consteval bool welded_for(std::meta::info type, lang L)
Is type welded for language L — i.e.
consteval void assert_callable_bindable()
Assert a function/method/operator/constructor signature binds, unless trusted.
consteval void assert_bindable()
Hard error the instant welder would bind an unbindable type.
consteval bool bindable()
Is T bindable to language L under backend B?
consteval bool trusted_for(std::meta::info member, lang L)
Does member carry a trust_bindable mark covering language L?
lang
The target languages welder ships rods for — but not the whole value space.
consteval void assert_setter_bindable()
Assert a property setter's parameter binds, unless trusted — the write half of the getter/setter mach...
consteval void assert_member_bindable()
Assert the type of a data member / namespace variable binds, unless trusted.
consteval void assert_signature_bindable()
Assert every parameter type and the (non-void) return type of Fn binds.
constexpr bool trust_bindable
The type-level trust customization point: specialize to true to trust T wherever it appears (member,...
consteval void assert_operands_bindable()
Assert the operand types of an operator<=> overload bind, unless the overload is trusted — the compar...
Language-agnostic resolution: given a reflected type/member and a target language,...
One row of the element-wise STL-wrapper table.
std::size_t values
Leading arguments to recurse; 0 = all.
std::meta::info tmpl
The class template, e.g.
The default registration oracle of the bindability gate: a program-defined class/enum type counts as ...
static consteval bool counts_as_registered(std::meta::info type, lang L)
Does welding under this policy provide a registration for type?