C++ STL Set Erase by Value
std::set
abides by associative container requirements of 26.2.6 associative.reqmts.
It returns the number of actual erased elements, which for std::set
must be zero or one, dependent on existence. Per 26.2.6.1 associative.reqmts.except, it is only guaranteed not to throw if the container comparator (which can be customized, obviously) does not throw when used during the search.
From cplusplus
(1) void erase (iterator position);
(2) size_type erase (const value_type& val);
(3) void erase (iterator first, iterator last);
Return value
For the value-based version (2), the function returns the number of elements erased.
Member type size_type is an unsigned integral type
So it returns 0 if no elements are erased.