From ae99a2124da32e4d2474e6dc6cf54322b688b743 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 24 Mar 2025 18:10:30 +0000 Subject: Use is_base_of_v instead of is_convertible_v to choose OtherObjects --- lib/collection.h | 6 +++--- test/test-collection.cpp | 4 ++++ ui/gameMainWindow.cpp | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/collection.h b/lib/collection.h index b786e2f..8e9cf1a 100644 --- a/lib/collection.h +++ b/lib/collection.h @@ -236,12 +236,12 @@ protected: } template - requires((std::is_convertible_v || ...)) + requires((std::is_base_of_v || ...)) [[nodiscard]] consteval static bool idx() { size_t typeIdx = 0; - return ((typeIdx++ && std::is_convertible_v) || ...); + return ((typeIdx++ && std::is_base_of_v) || ...); } template @@ -249,7 +249,7 @@ protected: constexpr const auto & containerFor() const { - if constexpr ((std::is_convertible_v || ...)) { + if constexpr ((std::is_base_of_v || ...)) { return std::get()>(otherObjects); } else { diff --git a/test/test-collection.cpp b/test/test-collection.cpp index a399845..90a3bd1 100644 --- a/test/test-collection.cpp +++ b/test/test-collection.cpp @@ -113,6 +113,10 @@ BOOST_AUTO_TEST_CASE(a_sub) BOOST_AUTO_TEST_CASE(filter) { + static_assert(TestCollection::idx() == 0); + static_assert(TestCollection::idx() == 0); + static_assert(TestCollection::idx() == 0); + static_assert(TestCollection::idx() == 0); create(); BOOST_CHECK_EQUAL(1, apply(&Base::yes)); BOOST_CHECK_EQUAL(0, apply(&Base::yes)); diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp index 07901b3..f8c568b 100644 --- a/ui/gameMainWindow.cpp +++ b/ui/gameMainWindow.cpp @@ -80,7 +80,7 @@ GameMainWindow::content(const SceneShader & shader, const Frustum & frustum) con renderable->render(shader, frustum); } } - gameState->world.apply(&Renderable::render, shader, frustum); + gameState->world.apply(&Renderable::render, shader, frustum); uiComponents.apply(&WorldOverlay::render, shader, frustum); } @@ -93,7 +93,7 @@ GameMainWindow::environment(const SceneShader &, const SceneRenderer & r) const void GameMainWindow::lights(const SceneShader & shader) const { - gameState->world.apply(&Renderable::lights, shader); + gameState->world.apply(&Renderable::lights, shader); } void @@ -104,5 +104,5 @@ GameMainWindow::shadows(const ShadowMapper & shadowMapper, const Frustum & frust renderable->shadows(shadowMapper, frustum); } } - gameState->world.apply(&Renderable::shadows, shadowMapper, frustum); + gameState->world.apply(&Renderable::shadows, shadowMapper, frustum); } -- cgit v1.2.3