Skip to content

fix: do not create map cells when adding or subtracting zero - #441

Merged
HDembinski merged 1 commit into
boostorg:developfrom
henryiii:fix/map-storage-zero-add-sub
Jul 30, 2026
Merged

fix: do not create map cells when adding or subtracting zero#441
HDembinski merged 1 commit into
boostorg:developfrom
henryiii:fix/map-storage-zero-add-sub

Conversation

@henryiii

@henryiii henryiii commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

map_impl::reference::operator+= and operator-= emplaced a cell for a missing index even when the result stayed as default value_type{}. Compute the result in a temporary and emplace only if it is non-default, as operator/= already does.

First half of #440, the simple fix.

Assisted-by: ClaudeCode:claude-opus-5

map_impl::reference::operator+= and operator-= emplaced a cell for a
missing index even when the result stayed at value_type{}. Compute the
result in a temporary and emplace only if it is non-default, as
operator/= already does.

Assisted-by: ClaudeCode:claude-opus-5
@henryiii

Copy link
Copy Markdown
Contributor Author

Update: actually fixing this fully isn't bad at all (compared to trying to patch it downstream in boost-histogram, especially!), so I'm going to make an alternative full-fix PR in a moment.

@HDembinski
HDembinski merged commit ff4f38c into boostorg:develop Jul 30, 2026
9 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