boostorg / boostorg/msm

Bug in `push_to_map_of_vec` template

Open
#98 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
40
Forks
59
PR merge metrics
No merged PRs in 30d

Description

`push_to_map_of_vec` constructs a new fusion map from scratch using `make_vector` and `make_pair`, which only contains the single new key-value pair being added. ([ref](https://github.com/boostorg/msm/blob/develop/include/boost/msm/back11/dispatch_table.hpp#L202))

This approach:
- Discards all existing entries in the original map.
- Only preserves the current key-value pair being processed.
- Fails to maintain the accumulated state information across multiple operations.
---
Here’s how I think this can be fixed:
- Convert the map to a vector representation
- Remove the existing entry for the key (if present)
- Create a new entry with the updated vector (original vector + new element)
- Add the new entry back to the vector
- Convert back to map format
---
The fix would maintain the same interface while correcting the fundamental logic error in map manipulation.
I wanted to run it through you and get your feedback @henry-ch before raising a bugfix PR. Please let me know your thoughts on this!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.