Skip to content
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

fix: to avoid the copy #548

Merged

Conversation

YuanYuYuan
Copy link
Contributor

@YuanYuYuan YuanYuYuan commented Mar 14, 2025

To address the warning in #546.

--- stderr: rmw_zenoh_cpp
/workspace/ws-whole-rolling/src/rmw_zenoh/rmw_zenoh_cpp/src/detail/graph_cache.cpp: In function ‘rmw_ret_t rmw_zenoh_cpp::{anonymous}::fill_names_and_types(const rmw_zenoh_cpp::GraphNode::TopicMap&, rcutils_allocator_t*, rmw_names_and_types_t*)’:
/workspace/ws-whole-rolling/src/rmw_zenoh/rmw_zenoh_cpp/src/detail/graph_cache.cpp:773:64: warning: loop variable ‘item’ of type ‘const std::pair<std::__cxx11::basic_string<char>, std::unordered_map<std::__cxx11::basic_string<char>, std::unordered_map<std::__cxx11::basic_string<char>, std::shared_ptr<rmw_zenoh_cpp::TopicData> > > >&’ binds to a temporary constructed from type ‘const std::pair<const std::__cxx11::basic_string<char>, std::unordered_map<std::__cxx11::basic_string<char>, std::unordered_map<std::__cxx11::basic_string<char>, std::shared_ptr<rmw_zenoh_cpp::TopicData> > > >’ [-Wrange-loop-construct]
  773 |   for (const std::pair<std::string, GraphNode::TopicTypeMap> & item : entity_map) {
      |                                                                ^~~~
/workspace/ws-whole-rolling/src/rmw_zenoh/rmw_zenoh_cpp/src/detail/graph_cache.cpp:773:64: note: use non-reference type ‘const std::pair<std::__cxx11::basic_string<char>, std::unordered_map<std::__cxx11::basic_string<char>, std::unordered_map<std::__cxx11::basic_string<char>, std::shared_ptr<rmw_zenoh_cpp::TopicData> > > >’ to make the copy explicit or ‘const std::pair<const std::__cxx11::basic_string<char>, std::unordered_map<std::__cxx11::basic_string<char>, std::unordered_map<std::__cxx11::basic_string<char>, std::shared_ptr<rmw_zenoh_cpp::TopicData> > > >&’ to prevent copying
---

@ahcorde ahcorde merged commit 1e0a028 into ros2:ahcorde/rolling/topic_map Mar 14, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants