٪ereAin'tNoSuch٪ingAsA,配音秀里的视频怎么下载

视频 3
ereAin'tNoSuchingAsAUniversalReference ereAin'tNoSuchingAsAUniversalReference JonathanWakely RedHat 1of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference UniversalReferences ScoMeyers'sterm(Overload111,blog,Channel9video)T&&Doesn'tAlwaysMean"RvalueReference" 2of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference UniversalReferences Scopresentsaveryusefulmodelforunderstandingfunctiontemplatessuchas: templatevoidfunc(T&&arg){} Whichcanbepassedlvalueorrvaluearguments: inti=0; func(i ); func(i+1); func("cat"s); //lvalue//rvalue//rvalue 3of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference UniversalReferences templatevoidfunc(T&&){} "eessenceoftheissueisthat"&&"inatypedeclarationsometimesmeansrvaluereference,butsometimesitmeanseitherrvaluereferenceorlvaluereference." UnlessstatedotherwiseallquotesintheseslidesarefromMeyers,2012,'UniversalReferencesinC++11',Overload,no.111,p.8-12. 4of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference UniversalReferences Scointroducesnewterminologyfortheservalue-or-lvaluereferences: "Suchunusuallyflexiblereferencesdeservetheirownname.Icallthemuniversalreferences.""IfavariableorparameterisdeclaredtohavetypeT&&forsomededucedtypeT,thatvariableorparameterisauniversalreference." (isincludestypesdeducedwithauto&&becauseautousesthesamerulesastemplateargumentdeduction) 5of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference Wedon'tneednostinkin'abstractions!
UniversalreferencesareausefulmodelforreadingandunderstandingtemplatecodeinmodernC++,everyoneshouldreadthearticleButordingtotheC++standard(andpiler)…ereain'tnosuchthingasauniversalreference!
estandard(pilers)onlyknowaboutlvaluereferencesandrvaluereferencesAndSco'srequirementthattheremustbeadeducedtypeinvolvedmeanstherearecasesthataren'texplainedbyuniversalreferences 6of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference Notauniversalreference templateclassWrapper{public:Wrapper(T&&t)//notdeduced:wrapped(std::forward(t)){}//...private:Twrapped;}; templateWrapperwrap(T&&t)//deduced{returnWrapper{std::forward(t)};} 7of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference Behindthecurtain erearetwopropertiesoftheC++languagethatexplaineverythingcoveredbythetermuniversalreferences,andothercasestoo:ReferencecollapsingAspecialcaseintheargumentdeductionrules 8of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference ReferenceCollapsing Let'sdeclareasimpletypedefforareferencetype: typedefint& intlref; Andthenapplysometransformations: typedefintlref&intlref2;typedefintlref&&intlref3; Westillhavethesametype: is_same//true,int&is_same//true,int& 9of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference ReferenceCollapsing Usingatypedefforanrvalue-referencetype: typedefint&& intrref; enapplyingthesametransformations: typedefintrref&intlref4;typedefintrref&&intrref2; Wedon'talwaysgetthesametype: is_same//false,int&is_same//true,int&& 10of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference ReferenceCollapsing WecanuseC++11aliastemplatestoperformthesesametransformations:templateusingref=T&;templateusingrefref=T&&;is_same,int&>is_same,int&>is_same,int&>is_same,int&&>is_same,int&>is_same,int&&> 11of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference ReferenceCollapsing esecorelanguagerulesforreferencecollapsingaremodelledbytransformationtraitsinthestandardlibrary: add_lvalue_reference::typeadd_lvalue_reference::typeadd_lvalue_reference::type ⇒int&⇒int&⇒int& add_rvalue_reference::typeadd_rvalue_reference::typeadd_rvalue_reference::type ⇒int&&⇒int&⇒int&& ispropertyofC++iswhystd::moveisdeclaredtoreturnremove_reference::type&&andnotsimplyT&&,youcan'tjustappend&&toatypeandexpecttogetanrvalue-reference 12of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference ReferenceCollapsing eexactsameruleswe'veseenforreferencecollapsingintypedefsalsoapplyinothercontexts,suchasfunctionparameters:voidfunc(intlref&);voidfunc(ref);voidfunc(intlref&&);voidfunc(refref); Allthosedeclarationsarethesamefunctionas:voidfunc(int&); 13of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference ExplicitTemplateArguments Usingthisfunctiontemplate:templatevoidfunc(T&&){} WecansubstitutethetypeTusinganexplicittemplateargument:func
(1);//func(int&&)inti;func(i);//func(int&)func
(1);//func(int&&) 14of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference Notauniversalreference templateclassWrapper{public:Wrapper(T&&t)//notdeduced,butcollapses:wrapped(std::forward(t)){}//...private:Twrapped;}; templateWrapperwrap(T&&t)//deduced{returnWrapper{std::forward(t)};} 15of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference TemplateArgumentDeduction Usingthesamefunctiontemplate: templatevoidfunc(T&&){} WearenowreadytounderstandwhathappenswhenthetypeTisdeduced: func
(1);//func(int&&) inti;func(i); //func(int&) 16of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference Deductionoflvalue-refs templatevoidfunc(T&&){} inti;func(i); //func(int&) ekeythingtonoticehere,whichisnotatallobvious,isthat AfunctiontemplatewithaparameterlikeT&&allowsthetemplateparameterTtobededucedasanlvaluereferencetype. 17of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference Deductionoflvalue-refs isall-importantruleaboutdeducinglvaluereferencetypesishardtofindinthestandardandquiteunderstated:"[…]IfPisanrvaluereferencetoacv-unqualifiedtemplateparameterandtheargumentisanlvalue,thetype"lvaluereferencetoA"isusedinplaceofAfortypededuction.[…]" ISO/IEC14882:2011,ProgrammingLanguages—C++,[temp.deduct.call]§14.8.2.1¶
3 18of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference UniversalReferences Firstthereisamountain-thenthereisnomountain-thenthereis—Zenproverb Althoughit'svaluabletounderstandwhatyourcodeisactuallydoing,universalreferenceareausefulmodelforreadingandunderstandingC++11code,eveniftheyaren'treallythere!
19of20 ACCU2014 ereAin'tNoSuchingAsAUniversalReference eseslidesareavailableathps:///u/u2014 YoucandownloadandviewtheHTMLversionoftheseslidesmandslike:gitcloneu2014.gitfirefoxu2014/tanstaaur.html 20of20 ACCU2014

标签: #视频 #快手 #水印 #自己的 #机里 #水印 #视频 #淘宝