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

Create C++ enumerate functions #52

Open
jojongx opened this issue Feb 7, 2025 · 3 comments
Open

Create C++ enumerate functions #52

jojongx opened this issue Feb 7, 2025 · 3 comments
Assignees

Comments

@jojongx
Copy link

jojongx commented Feb 7, 2025

We need a C++ template function that features the equivalent of Python's enumerate. This should be placed in mil_tools::itertools.

@jojongx jojongx self-assigned this Feb 7, 2025
@andrew-aj
Copy link
Member

You could implement something like
this. It allows you to get access to a tuple that you can unpack and refer to the elements with their own variable names like in python.

@jojongx
Copy link
Author

jojongx commented Feb 9, 2025

Does something of this format need to be added to the CMakeLists.txt?

ament_add_gtest(${PROJECT_NAME}_string_test test/string.cpp)
  target_include_directories(${PROJECT_NAME}_string_test PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
  )
  target_link_libraries(${PROJECT_NAME}_string_test ${PROJECT_NAME})

I just took this snippet from the file for an example.

I already implemented the enumerate variant from the resource.

@cbrxyz
Copy link
Member

cbrxyz commented Feb 9, 2025

You will need to modify CMakeLists.txt in some way, how you modify it will depend on your implementation. You probably will need to add a new ament_add_gtest call for (presumably) your new file!

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

No branches or pull requests

3 participants