Skip to content

Throw std::invalid_argument when empty key is used - #11

Merged
rigtorp merged 1 commit into
masterfrom
feat/throw-on-empty-key
Nov 14, 2026
Merged

rigtorp merged 1 commit into
masterfrom
feat/throw-on-empty-key

Conversation

@rigtorp

@rigtorp rigtorp commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace assert on empty key in emplace_impl and find_impl with a [[unlikely]] check calling a [[noreturn]] noinline detail::throw_empty_key() helper
  • Remove unused <cassert> include
  • Add unit tests in src/HashMapTest.cpp covering insert, emplace, operator[], find, count, at, and erase with the empty key
  • Document the behavior in README.md

Test plan

  • clang-format --dry-run --Werror include/rigtorp/HashMap.h src/*.cpp
  • cmake --build --preset debug --parallel && ctest --preset debug
  • cmake --build --preset release --parallel && ctest --preset release

@rigtorp
rigtorp force-pushed the feat/throw-on-empty-key branch 2 times, most recently from ac2b97d to 3ff828e Compare November 14, 2026 17:37
@rigtorp
rigtorp force-pushed the feat/throw-on-empty-key branch from 3ff828e to c002215 Compare November 14, 2026 17:39
@rigtorp
rigtorp merged commit 16d0eea into master Nov 14, 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.

1 participant