Skip to content

Implement multi-interface best::dyns#35

Merged
mcy merged 1 commit intomainfrom
dyn-multi
Feb 24, 2025
Merged

Implement multi-interface best::dyns#35
mcy merged 1 commit intomainfrom
dyn-multi

Conversation

@mcy
Copy link
Owner

@mcy mcy commented Feb 23, 2025

This change makes best::dyn a variadic template, so that you can have e.g. best::dynptr<reader, writer>, much like Rust has &dyn Read + Write. To enable this, the interface for implementing interfaces has changed.

  • best::itable is the new name for best::vtable, which in turn is now an alias for extracting a BestVtable from an interface type, which is the new name for BestFuncs.
  • BestImplements now needs to return a best::vtable<I> by value, and machinery inside of best::itable will automatically create a global variable for the result; best::itable::of now does more than just call BestImplements. This makes BestImplements very painless to implement by hand.
  • best::itable<I, J, ...> no longer has an operator->, since there is more than one vtable; operator[] can be used to get the vtable for a particular interface.
  • best::dynptr<I, J, ...> provides access to the call interfaces for I and J via operator[] too.
  • best::dyn::of is now best::as_dyn (which itself was renamed to best::dyn_of). This is so that it can be called with const interface values.
  • All interfaces must derive best::interface_base, which allows us to force all interfaces to provide an of() static function, instead of having ti be convention.

Also fixed best::row::as_ref() being completely broken. Oops.

@mcy mcy merged commit 12a6bc9 into main Feb 24, 2025
3 checks passed
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