Skip to content

[NFC] Templatize makeBlock so it can be used with any iterable #5583

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
Mar 16, 2023

Conversation

tlively
Copy link
Member

@tlively tlively commented Mar 16, 2023

Replace the different overloads we previously had for different kinds of
containers with generic templates. We still need dedicated overloads for
std::initializer_list because it is never inferred in a template context,
though. Also, since std::initializer_list does not allow subscripting, update
the arena vector implementation to use iterators instead now that initializer
lists can be passed down to that layer without being reified as vectors.

Replace the different overloads we previously had for different kinds of
containers with generic templates. We still need dedicated overloads for
`std::initializer_list` because it is never inferred in a template context,
though. Also, since `std::initializer_list` does not allow subscripting, update
the arena vector implementation to use iterators instead now that initializer
lists can be passed down to that layer without being reified as vectors.
@tlively tlively requested a review from kripken March 16, 2023 21:02
@tlively
Copy link
Member Author

tlively commented Mar 16, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Thanks!


template<typename T>
using bool_if_not_expr_t =
std::enable_if_t<std::negation_v<std::is_convertible<T, Expression*>>,
Copy link
Member

Choose a reason for hiding this comment

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

Btw, any idea why I couldn't get this to work with std::is_base_of instead of is_convertible?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it has to do with having to remove the pointer, presumably using std::remove_pointer, although TBH I couldn't get that working either, so I'm definitely missing something else there, too.

@tlively tlively merged commit 121d157 into main Mar 16, 2023
@tlively tlively deleted the template-makeblock branch March 16, 2023 22:35
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
…Assembly#5583)

Replace the different overloads we previously had for different kinds of
containers with generic templates. We still need dedicated overloads for
`std::initializer_list` because it is never inferred in a template context,
though. Also, since `std::initializer_list` does not allow subscripting, update
the arena vector implementation to use iterators instead now that initializer
lists can be passed down to that layer without being reified as vectors.
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