Question Details

No question body available.

Tags

c++ g++ c++23 unordered-set

Answers (1)

Accepted Answer Available
Accepted Answer
July 23, 2025 Score: 6 Rep: 10,532 Quality: High Completeness: 60%

Your code is correct, however the overload you are looking for is just quite new and has not yet been adopted by the major compilers (it works for the latest MSVC, though). Since you can still use the transparent comparison to find the iterator, just use it for erasure:

if (const auto it = uset.find("42"); it != uset.end()) { uset.erase(it); }