From 47d0a4328f2d652dc0913767ccf18fba646bf803 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 20 Dec 2024 09:59:55 +0100 Subject: [PATCH] view: join -> operator| --- src/entt/entity/view.hpp | 14 ++++++-------- test/entt/entity/view.cpp | 5 +++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index da15889cb..7488e5143 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -644,13 +644,12 @@ public: /** * @brief Combines a view and a storage in _more specific_ view. - * @tparam OGet Type of storage to join the view with. - * @param other The storage for the type to join the view with. + * @tparam OGet Type of storage to combine the view with. + * @param other The storage for the type to combine the view with. * @return A more specific view. */ template - [[nodiscard]] auto join(OGet &other) const noexcept { - static_assert(std::is_base_of_v, "Unexpected storage type"); + [[nodiscard]] std::enable_if_t, basic_view, exclude_t>> operator|(OGet &other) const noexcept { return *this | basic_view, exclude_t<>>{other}; } @@ -1086,13 +1085,12 @@ public: /** * @brief Combines a view and a storage in _more specific_ view. - * @tparam OGet Type of storage to join the view with. - * @param other The storage for the type to join the view with. + * @tparam OGet Type of storage to combine the view with. + * @param other The storage for the type to combine the view with. * @return A more specific view. */ template - [[nodiscard]] auto join(OGet &other) const noexcept { - static_assert(std::is_base_of_v, "Unexpected storage type"); + [[nodiscard]] std::enable_if_t, basic_view, exclude_t<>>> operator|(OGet &other) const noexcept { return *this | basic_view, exclude_t<>>{other}; } diff --git a/test/entt/entity/view.cpp b/test/entt/entity/view.cpp index ab5e5229a..6f03dea83 100644 --- a/test/entt/entity/view.cpp +++ b/test/entt/entity/view.cpp @@ -1541,8 +1541,9 @@ TEST(View, Pipe) { entt::basic_view view3{std::get<2>(storage)}; entt::basic_view view4{std::as_const(std::get<3>(storage))}; - testing::StaticAssertTypeEq(storage))), decltype(view1 | view3)>(); - testing::StaticAssertTypeEq(std::as_const(storage)))), decltype(view1 | view4)>(); + testing::StaticAssertTypeEq(storage)), decltype(view1 | view3)>(); + testing::StaticAssertTypeEq(std::as_const(storage))), decltype(view1 | view4)>(); + testing::StaticAssertTypeEq(storage) | view4), decltype(view1 | view3 | view4)>(); testing::StaticAssertTypeEq, const entt::storage>, entt::exclude_t, entt::storage>>, decltype(view1 | view2)>(); testing::StaticAssertTypeEq, entt::storage>, entt::exclude_t, const entt::storage>>, decltype(view2 | view1)>();