Several new features of C + + 11

Source: Internet
Author: User

1,range for; alto

for (const Auto& Agent:componentagents_)
{
Agent->interface ();
}

See http://www.cnblogs.com/h46incon/archive/2013/06/02/3113737.html

The latest C + + standard updates the features of the Auto keyword
In addition to having the original meaning, it also adds a type derivation feature similar to other high-level languages
Use Auto to replace the type of the variable,
If initialized with a definite type of initialization variable, you can use the Auto keyword
such as int i=10; Auto A = i; So a is an int type.
This is useful for reducing redundant code when using some template classes
See Http://zhidao.baidu.com/link?url=6_MLuvtOysRI0Mar386KMVr4_akcjfecdhUkg14esU7wM7G3UAtoR5ngvT50zM5yqdjxzxWxtB6t4Isn3Zh1W_

2,LANBDA-expression

    The type of a closure cannot is named, but can is inferred with auto    auto func1 = [] (int i) {return i+4;};    

[ capture ] ( params ) mutable exception attribute -> ret { body }

capture Specifies a list of external variables that are visible within the code of a lambda expression within the visible domain scope, as explained below:

    • [a,&b]A variable is captured in the form of a value, and B is captured as a reference.
    • [this]Captures the this pointer in a value manner.
    • [&]Captures all external automatic variables in a reference manner.
    • [=]All external automatic variables are captured in a value manner.
    • []No external variables are captured.

See http://www.cnblogs.com/haippy/archive/2013/05/31/3111560.html

Several new features of C + + 11

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.