Skip to content

value: model the variant_ish concept (index/valueless/visit)#1

Open
jcelerier wants to merge 1 commit into
mainfrom
variant-ish-conformance
Open

value: model the variant_ish concept (index/valueless/visit)#1
jcelerier wants to merge 1 commit into
mainfrom
variant-ish-conformance

Conversation

@jcelerier

Copy link
Copy Markdown
Member

Summary

jk::value keeps its variant in a .v member, so it matches none of the standard variant concepts — value.index() and an unqualified visit(f, value) don't resolve. Generic consumers that program against a variant interface (e.g. Avendish's pd/max/wasm back-end bindings) therefore can't accept a jk::value output directly.

This adds, on jk::value:

  • index() / valueless_by_exception() members,
  • an ADL-visible visit(f, value) (lvalue/const/rvalue) forwarding to the configured variant's visit on .v.

No behaviour change for existing code (jk internals already call config::variant_ns::visit explicitly); this only makes jk::value model the variant interface for outside concept-based code.

Test plan

  • Header compiles standalone (-std=c++20) with the default std::variant config; lvalue/const/rvalue visit and index() resolve.
  • Validated end-to-end via score-addon-jk standalone pd/max/wasm builds (submodule bump).

🤖 Generated with Claude Code

jk::value wraps the variant in a member, so it satisfied none of the
variant concepts used by generic consumers (e.g. Avendish's back-end
bindings): value.index()/visit(f, value) didn't resolve. Forward the
variant interface (index, valueless_by_exception, and an ADL visit on
the wrapped member) so jk::value is usable directly as a variant value
without exposing .v at every call site.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant