Is std::set erase ( x ) implemented in STL same way erase ( collection.find( x ) ); (where x is const key_type&) does?
Is std::set erase ( x ) implemented in STL same way erase ( collection.find(
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m sure they’re likely to be quite similar, but they’ll have differences because one must handle an ‘unfound’ element in a certain way and the other doesn’t need to worry about that (and likely doesn’t in a non-debug build).
std::set::erase( const key_type& )will return0or1depending on if a matching element to erase is found.std::set::erase( iterator )returns nothing and has defined behavior only if the iterator passed in is dereferenceable. So if you pass infind(x)wherexisn’t in the set, you have a problem.