Simplify scene map construction and adjust ECS death-test conditionals#19
Closed
Thomas-Chqt wants to merge 4 commits intorefactorfrom
Closed
Simplify scene map construction and adjust ECS death-test conditionals#19Thomas-Chqt wants to merge 4 commits intorefactorfrom
Thomas-Chqt wants to merge 4 commits intorefactorfrom
Conversation
Thomas-Chqt
commented
Apr 23, 2026
Comment on lines
+74
to
+77
| , m_scenes(std::from_range, descriptor.scenes | std::views::transform([&](const auto& sceneDesc){ return std::make_pair(sceneDesc.first, Scene(assetManager, sceneDesc.second)); })) | ||
| , m_scenes(std::ranges::to<std::map<std::string, Scene>>( | ||
| descriptor.scenes | std::views::transform([&](const auto& sceneDesc) { | ||
| return std::make_pair(sceneDesc.first, Scene(assetManager, sceneDesc.second)); | ||
| }))) |
There was a problem hiding this comment.
Summary
- Updated
Game::Gameto use pipe-stylestd::ranges::to<std::map<...>>()form_scenesinitialization, matching the requested|operator style at the cited location insrc/Game.cpp. - Kept the existing transform lambda and behavior intact; only the range-to-map expression style was changed for consistency with review feedback.
- Committed the change on the current branch (
e386593) and created a follow-up PR message via themake_prtool.
Testing
- ✅
cmake --build build -j2 - ✅
cd build && ctest --output-on-failure
Comment on lines
+104
to
+109
| std::map<std::string, GE::Scene::Descriptor> scenes; | ||
| for (const auto& [_, sceneDescriptor] : m_scenes) | ||
| scenes.emplace(sceneDescriptor.name, sceneDescriptor); | ||
|
|
||
| return { | ||
| .scenes = std::map<std::string, GE::Scene::Descriptor>( | ||
| std::from_range, | ||
| m_scenes | std::views::transform([](const auto& pair){ return std::make_pair(pair.second.name, pair.second); }) | ||
| ), | ||
| .scenes = std::move(scenes), |
Owner
Author
There was a problem hiding this comment.
Use to std map here too
There was a problem hiding this comment.
Summary
- Updated
Project::makeGameDescriptor()to construct.sceneswith a ranges pipeline and pipe-stylestd::ranges::to<std::map<...>>(), matching the requested style consistency withGame.cpp. editor/Project.cppL102-L112 - Specifically, the map now comes from
m_scenes | std::views::values | std::views::transform(...) | std::ranges::to<std::map<std::string, GE::Scene::Descriptor>>(). editor/Project.cppL105-L110 - Committed on branch
workwith message:Use pipe-style std::ranges::to for project scenes map(commit10830e6).
Testing
- ✅
cmake --build build - ✅
cd build && ctest --output-on-failure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
std::from_rangeto improve clarity and compatibility when constructingm_scenesand the game descriptor scenes map.NDEBUG.Description
std::from_range/ views-based scene-to-map construction inProject::makeGameDescriptor()with an explicit loop that builds astd::map<std::string, GE::Scene::Descriptor>and assigns it to.scenes.std::from_rangeinitializer form_scenesinGame::Gamewith a simple loop thatemplaces each scene name andSceneinstance intom_scenes.tests/ECS_testCases.cppto use#ifndef NDEBUGto runEXPECT_DEATHonly in debug builds and remove theEXPECT_ANY_THROWrelease-path checks.Testing
tests/ECS_testCases.cppand the ECS tests, and they completed successfully.GameandProject, and the build succeeded.Codex Task