Erase of STL

Source: Internet
Author: User

Today, we found that some STL: map code runs well in windows, but it cannot be compiled in Linux: "no match for 'operator = 'in' iter = ".

It is actually a simple line of code:

Iter = map. Erase (ITER)

The description of MAP: erase on msdn is as follows:

Iterator erase (iterator it );
Iterator erase (iterator first, iteratorlast );
Size_type erase (const key & Key );

After reading for a long time, I did not find any errors. I went to the Standard C/C ++ document and found the differences:

Void erase (iteratorpos );
Void erase (iteratorstart, iteratorend );
Size_type erase (const key_type & Key );

So I changed the code to this, which is available on both platforms:

Map. Erase (ITER ++)

I wonder why Windows does not use standard STL, So I compared the msdn and C ++ quasi-template libraries and found that the list and vector erase methods both return iterator,

For other containers, the standard library's erase method is in the above format.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.