c++14 Function return type auto
Two ,lambda parameter auto
stay C++11 in ,lamdba Function arguments need to be declared as concrete types .C++14 Relaxed this requirement , allow lambda Function parameter types use type specifiers auto.
Simple code , And enhance refactoring .
Three ,[[deprecated]]
utilize deprecated Miscellaneous notes , Function can be indicated , Type or any other identifier is no longer supported by future versions , Or they should not be used again .
#pragma deprecated( identifier1 [,identifier2, …] )
Four ,constexpr

constexpr It means that this thing can be calculated at compile time ( The premise is that in order to calculate what it depends on, it can also be calculated at compile time ). and const It only ensures that the runtime is not modified directly ( But it could still be a dynamic variable ),const Decorated with type ,constexpr It's the code used to calculate the value .

stay C++11 in , use constexpr Declared functions can be executed at compile time , Generate a value , Used where constant expressions are required , For example, as the shape parameter of initialization template .C++11 Of constexpr Function can only contain one expression ,C++14 Relaxed these restrictions , Support such as if
and switch Equal conditional statement , Support cycle , This includes interval based (range) Of for loop .

C++17 One ,auto

from c++11 start ,auto Keyword can deduce the type of variable through initializer . stay c++14 in ,auto Further improve the ability of keywords , Able to pass return Statement derived function return type .
use auto Keywords can improve coding efficiency , At the same time, it can simplify the reconstruction process . however ,C++11 In auto deduction , Often the result is different from the expectation .
Two ,lamda
lambda It's also c++11 Introduced in , stay C++11 in ,lambda Expressions can only be captured with this,this Is a read-only reference to the current object .
stay C++17 in , Can capture this, this Is a copy of the current object , Capture a copy of the current object , Ensures that the current object is released ,
lambda Expression can be called safely this Variables and methods in .
Three , Conditional statement initialization
c++17 Supported in if perhaps switch Initialization in statement , This ability can make the code more concise .

Four ,std::optional
std::optional Indicates a possible value . When we create an object through a function , Error codes are usually returned through functions , And return the object itself through the parameter .
has_value() // Check whether the object has a value
value() // Returns the value of the object , Thrown if the value does not exist std::bad_optional_access abnormal
value_or() // Return value when value exists , Return the default value when it does not exist
At the same time, there are other security functions

©2019-2020 Toolsou All rights reserved,
JS How to operate java Realize the function of grabbing red packets C Language programming to find a student's grade The United Nations 《 Glory of Kings 》 Please go to the studio : To save the earth Dialogue between apple and Nissan suspended ,Apple Car How's it going ?CSS architecture design China's longest high speed rail officially opened ! The fastest way to finish the race 30.5 hour First knowledge MySQL Comprehensive review ( dried food )2021 year 1 Monthly programmer salary statistics , average 14915 element How to use it quickly html and css Write static page