Recruit easy to learn, veterans easy to use----C + + (C++11 's learning and finishing---how to reduce the amount of code, enhance the readability of the code)

Source: Internet
Author: User

1.auto Type deduction

The biggest advantage of auto derivation is that it simplifies code when you have a complex type variable declaration with an initialization expression.

Auto's second advantage is to eliminate the programmer's trouble with some type declarations, or to avoid some errors in type declarations.

The third advantage of auto is that its "adaptive" performance can support generics programming to some extent.

Four terms of use for auto:

1) Function: cannot be a formal parameter

2) struct: cannot be a static type

3) Array: cannot declare an array

4) Template instantiation: cannot be used as a template parameter

2.decltype Derivation Details

1) If E is a cousin expression or a class member access expression without parentheses, then Decltype (e) is the entity named by E;

2) Otherwise, is the type of E is T, if E is a dead value, then Decltype (e) is t&&;

3) Otherwise, the type that is set E is T, if E is an lvalue, then Decltype (e) is t&;

4) Otherwise, the type that is set E is T, then Decltype (e) is t;

Inheritance and redundancy of 3.CV limiters

Decltype can be redundant, but its deduced members cannot inherit const,volatile.

4. Range-based for loop (do it faster and better than For_each)

5. Trace type return (the ability to really release C++11 's generic programming and more convenient use of templates)

Recruit easy to learn, veterans easy to use----C + + (C++11 's learning and finishing---how to reduce the amount of code, enhance the readability of the code)

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.