Valid STL Clause 3, valid tivestl Clause 3

Source: Internet
Author: User

Valid STL Clause 3, valid tivestl Clause 3
Make sure that the objects in the container are copied correctly and efficiently.

When using the STL template, we must think about the copy issue. If STL stores custom types. The following problems may occur:

First

To avoid the copy process from becoming a bottleneck in program operation, we choose to store custom pointers. However, the wild pointer problem is easy to occur here, so we need to use the smart pointer shared_pre to avoid it.

Next

If the storage type is the base class, when we store the derived class, truncation occurs, that is, only the base class is copied, and the derived class is lost.

Last

Compared with arrays, vector has its own uniqueness. The most obvious difference is the dynamic growth of length.

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.