view: avoid warnings and add a test to trigger them on the CI in future - close #1328

This commit is contained in:
skypjack
2026-03-11 16:38:01 +01:00
parent 93cb729322
commit 1de7c8bbd2
2 changed files with 17 additions and 1 deletions

View File

@@ -53,7 +53,7 @@ template<typename Result, typename View, typename Other, std::size_t... GLhs, st
Result elem{};
// friend-initialization, avoid multiple calls to refresh
elem.pools = {view.template storage<GLhs>()..., other.template storage<GRhs>()...};
auto filter_or_placeholder = [placeholder = elem.placeholder](auto *value) { return (value == nullptr) ? placeholder : value; };
[[maybe_unused]] const auto filter_or_placeholder = [placeholder = elem.placeholder](auto *value) { return (value == nullptr) ? placeholder : value; };
elem.filter = {filter_or_placeholder(view.template storage<sizeof...(GLhs) + ELhs>())..., filter_or_placeholder(other.template storage<sizeof...(GRhs) + ERhs>())...};
elem.refresh();
return elem;

View File

@@ -1654,6 +1654,22 @@ TEST(View, Pipe) {
ASSERT_NE(pack32.storage<float>(), nullptr);
}
TEST(View, PipeNoFilter) {
std::tuple<entt::storage<int>, entt::storage<double>> storage{};
const std::array entity{entt::entity{1}, entt::entity{3}};
std::get<0>(storage).emplace(entity[0u]);
std::get<1>(storage).emplace(entity[0u]);
std::get<0>(storage).emplace(entity[1u]);
entt::basic_view view1{std::forward_as_tuple(std::get<0>(storage))};
const entt::basic_view view2{std::forward_as_tuple(std::as_const(std::get<1>(storage)))};
ASSERT_TRUE((view1 | view2).contains(entity[0u]));
ASSERT_FALSE((view1 | view2).contains(entity[1u]));
}
TEST(View, PipeWithPlaceholder) {
entt::storage<void> storage{};
const entt::entity entity{0};