diff --git a/include/jk/value.hpp b/include/jk/value.hpp index 3974041..289e82c 100644 --- a/include/jk/value.hpp +++ b/include/jk/value.hpp @@ -1,6 +1,9 @@ #pragma once #include +#include +#include + namespace jk { struct value; @@ -63,7 +66,31 @@ struct value operator variant&&() && noexcept { return std::move(v); } bool operator==(const value& other) const noexcept = default; + + // Model avnd::variant_ish: the Avendish back-end bindings (pd / max / wasm) + // treat a value output as a variant (concept check + unqualified visit). Expose + // the variant interface so jk::value is usable directly, without libossia. + std::size_t index() const noexcept { return v.index(); } + bool valueless_by_exception() const noexcept { return v.valueless_by_exception(); } }; +// ADL hook for the bindings' unqualified visit(f, value): forward to the +// configured variant's visit on the wrapped member. +template +inline decltype(auto) visit(F&& f, value& self) +{ + return config::variant_ns::visit(std::forward(f), self.v); +} +template +inline decltype(auto) visit(F&& f, const value& self) +{ + return config::variant_ns::visit(std::forward(f), self.v); +} +template +inline decltype(auto) visit(F&& f, value&& self) +{ + return config::variant_ns::visit(std::forward(f), std::move(self.v)); +} + // clang-format on }