19#include <unordered_map>
20#include <unordered_set>
47namespace welder::inline v0 {
69template <caster_oracle B,
class T, lang L,
class Reg>
70consteval bool bindable();
97 {^^std::vector, 1}, {^^std::list, 1},
98 {^^std::deque, 1}, {^^std::set, 1},
99 {^^std::multiset, 1}, {^^std::unordered_set, 1},
100 {^^std::unordered_multiset, 1},
101 {^^std::map, 2}, {^^std::multimap, 2},
102 {^^std::unordered_map, 2}, {^^std::unordered_multimap, 2},
103 {^^std::optional, 1}, {^^std::shared_ptr, 1},
104 {^^std::unique_ptr, 1}, {^^std::pair, 2},
105 {^^std::array, 1}, {^^std::tuple, 0},
117 if (!std::meta::has_template_arguments(type))
119 const std::meta::info tmpl{std::meta::template_of(type)};
122 return w.values != 0 ?
static_cast<long>(w.values)
124 std::meta::template_arguments_of(type).size());
132template <std::meta::info Type, std::
size_t N>
134 std::array<std::meta::info, N> out{};
136 for (
auto arg : std::meta::template_arguments_of(Type)) {
153 return (
bindable<B,
typename [:Args[I]:], L, Reg>() && ...);
168template <caster_oracle B,
class T, lang L,
class Reg>
176 constexpr std::meta::info u{std::meta::dealias(
177 ^^std::remove_cv_t<std::remove_pointer_t<std::remove_cvref_t<T>>>)};
186 if constexpr (values >= 0) {
189 std::make_index_sequence<args.size()>{});
190 }
else if constexpr (B::template has_native_caster<typename [:u:]>) {
193 return Reg::counts_as_registered(u, L);
209template <caster_oracle B,
class T, lang L,
class Reg = welded_registration>
223template <caster_oracle B,
class T, lang L,
class Reg = welded_registration>
227 "welder: cannot bind this C++ type to the target language. Weld it with "
228 "[[=welder::weld(...)]], or register a backend type converter for it; "
229 "otherwise mark::exclude the member that uses it. The offending type is "
230 "the template argument of this assert_bindable<B, T, L> instantiation.");
241template <caster_oracle B, std::meta::info Fn, lang L,
class Reg, std::size_t... I>
257template <caster_oracle B, std::meta::info Fn, lang L,
258 class Reg = welded_registration>
263 constexpr std::size_t n{std::meta::parameters_of(Fn).size()};
264 if constexpr (n != 0)
266 if constexpr (!std::meta::is_constructor(Fn)) {
267 using R = [:std::meta::return_type_of(Fn):];
268 if constexpr (!std::is_void_v<R>)
286template <caster_oracle B, std::meta::info Member, lang L,
287 class Reg = welded_registration>
298template <caster_oracle B, std::meta::info Fn, lang L,
299 class Reg = welded_registration>
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::array< wrapper_spec, 18 > stl_wrappers()
The element-wise STL-wrapper table welder recurses into.
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 auto param_types()
A function's parameter types, as a static array of reflections.
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 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_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,...
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?