Reputation: 575
I've been comparing documentation for the multimap::erase
function. After checking out Josuttis and cplusplus.com, it looks as though there are three overloads:
void erase(iterator position);
size_type erase(const key_type& x);
void erase(iterator first, iterator last);
However, the MSDN documentaion appears to suggest three slightly different overloads:
iterator erase(iterator where);
iterator erase(iterator first, iterator last);
bool erase(key_type key)
Why the differences? Am I just being a bit slow and looking at the wrong docs, or has the standard moved on and I'm just looking at outdated documentation?
Upvotes: 0
Views: 215
Reputation: 18652
The MSDN documentation you linked to is the STL/CLR
version. That's a subset of the Standard C++ Library for use with C++ and the .NET Framework common language runtime (CLR).
The correct MSDN C++ documentation for std::multimap::erase
is here.
Upvotes: 1
Reputation: 122011
The link from MSDN appears to document a library that wraps the STL for use in CLR. The first code snippet is correct and is the same as that in C++03 standard, and only differs from the C++11 standard in the iterators
are const
. From section 23.4.5.1 Class template multimap overview of the C++11 standard:
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);
Upvotes: 2
Reputation: 14094
According to this, it actually depends on the version of the standard your STL is conforming to. What you read on MSDN is C++ 11, and on cplusplus.com it's for older C++.
Upvotes: 2
Reputation: 157484
The correct overloads are (from http://en.cppreference.com/w/cpp/container/multimap/erase):
void erase( iterator position ); (until C++11)
iterator erase( const_iterator position ); (since C++11)
void erase( iterator first, iterator last ); (until C++11)
iterator erase( const_iterator first, const_iterator last ); (since C++11)
size_type erase( const key_type& key );
The cplusplus.com documentation is out of date; the Microsoft documentation is simply incorrect (overloads possibly copied erroneously from map
documentation); it does say later that the third form returns a count of the number of elements removed so clearly cannot return bool
.
Upvotes: 2