-
-
Notifications
You must be signed in to change notification settings - Fork 903
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
Joining views with storages #1196
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #1196 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 158 158
Lines 26792 27027 +235
==========================================
+ Hits 26792 27027 +235 ☔ View full report in Codecov by Sentry. |
Out of curiosity, why not: auto view = registry.view<C1, const C2>() | dirty_entities; It seems more on the line of the already existing functionality. Any particular reasons for using a dedicate function instead? |
Purely a matter of semantics, since storages are a different type from views. Nothing against |
src/entt/entity/view.hpp
Outdated
* @sa operator| | ||
*/ | ||
template<typename OGet, typename = std::enable_if_t<std::is_lvalue_reference_v<OGet>>> | ||
[[nodiscard]] auto join(OGet &&other) const noexcept { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ehy, sorry for the late reply. I've been busy recently.
I think you can have OGet &other
and remove the is_lvalue_reference_v
check as a consequence, no? remove_reference_t
below is also useless then.
Same for the other join
. Am I missing something? 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh I'd swear I had a problem with the const
not propagating from storage to view earlier, I probably did something wrong... Anyway I just reverted the changes, let me know if you need anything else.
Looks like my playing with branches other than |
Views are pretty much a core utility of EnTT already and there is good support for many common operations. One of them is joining with other views, especially useful when one view might have named pools. However, the syntax becomes a little noisy when you need to join a view with one storage, which most often is a named
void
storage or a storage out of the registry (from my experience). To do this, we currently have to do something like:To address this, I propose to add a
join
function tobasic_view
, which works similarly to the existingoperator|
, except that it only accepts a storage as a parameter instead of a view. So the example before would now look like this:Now the function returns a new view, so you can chain
.join()
calls one after another. This is something of preference but I would advise to useoperator|
in that case.