New features for C + + 14

Source: Internet
Author: User
Tags deprecated

Reference Link: http://blog.jobbole.com/79228/ 1 return type deduction
In c++11, the lambda function parameter needs to be declared as a specific type. C++14 relaxed this requirement, allowing the lambda function parameter type to use the type specifier auto. The code is concise and can enhance refactoring. Actual use of template parameters
Auto lambda = [] (auto x, auto y) {return (x + y);} // equivalent to struct  <typename t,typename u>operatorconst{return (x+  = Unnamed_lambda ();

If a function has more than one return path, the value returned by each return path needs to have the same type.

Auto F (int  i) {  if0  )    return -1;   Else    return 2.0  // compile will error }

2 A lambda capture that can be initializedCaptures in lambda can be initialized, separated by commas, run from left to rightauto y = [&r = x, x = X+1] (->int {. /span> 3 [[deprecated]] propertyThe [[deprecated]] label is placed in front of the declaration-it can be a declaration of a class, variable, function, or some other entity, and is placed before the entity name, such as the Class,enum keyword. Flag obsolete definitions, not recommended
class [[deprecated]] flaky {}; [[Deprecated ("consider using something other than cranky")]] int cranky () {   return0int  main () {  flaky F;   return cranky ();}

Other

Binary constants are preceded by a prefix of 0b (or 0B), followed by a binary number.

Single quote character as a number separator, 1 million can be: 1 ' 000 ' 000.00 or 1 ' 0 ' 00 ' 0 ' 00.00

#include <iostream>intMain () {intval =0b11110000; Std::cout<<"Output Mask:"<< 0b1000'0001' +'0000<<"\ n"; Std::cout<<"proposed salary: $"<< -'000.00<<"\ n"; return 0;}

New features for C + + 14

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.