Skip to content

[embind] Use std::disjunction for checking policy arguments. #22603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

brendandahl
Copy link
Collaborator

This is a little cleaner than having to define a recursive template for each of these is<SomePolicy>. std::disjunction isn't available until c++17, so I also added a polyfill.

I also changed conjunction to use std::conjunction when it is available and polyfill otherwise.

This is a little cleaner than having to define a recursive template
for each of these `is<SomePolicy>`. std::disjunction isn't available until
c++17, so I also added a polyfill.

I also changed conjunction to use std::conjunction when it is available and
polyfill otherwise.
struct isNonnullReturn<> {
static constexpr bool value = false;
};
using isNonnullReturn = disjunction<std::is_same<nonnull<ret_val>, Policies>...>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

What are async and non_null in the above lines by the way? Are they special values defines somewhere, or just some kind of placeholder?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Policy args are basically options you can pass into function bindings. e.g.

   function('sleep', &sleep, async());
   function('constructor', &constructor, nonnull<ret_val>());

@brendandahl brendandahl merged commit df22009 into emscripten-core:main Sep 20, 2024
28 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.

2 participants