1 Std::ref () Implementing a reference wrapper
2 std::string string
1 Std::ref () Implementing a reference wrapper
The template function reference is not valid, so you need to reference the wrapper
Std::ref (), the function template directly references
1#include <iostream>2 using namespacestd;3 4Template <classT>5 voidCOM (T Arg)//The template function reference is not valid, so you need to reference the wrapper6 {7arg++;8Std::cout <<"void COM (T arg)"<< &arg << Std::endl;//not the same address .9 }Ten One voidMain () A { - intCountTen); - int& Rcount (count);//References the -Std::cout <<"the original value"<< Count << Std::endl;//Ten - -COM (&count);//parameter is address + -Std::cout <<"parameter is address"<< Count << Std::endl;//still ten + ACOM (rcount);//parameter is a reference at -Std::cout <<"parameter is a reference"<< Count << Std::endl;//still ten - -Std::cout <<"Main"<< &count << Std::endl;//not the same address . - - //std::ref (variable name), function template Direct reference inCOM (std::ref(count)); - toStd::cout <<"Reference Wrapper"<< Count << Std::endl;//become One + -System"Pause"); the}
2 std::string string
R "(You can remove the escape character inside the parentheses)"
1#include <iostream>2 3 voidMain ()4 {5 //R "(You can remove the escape character inside the parentheses)"6STD::stringPath = R"("D:\Program Files\tencent\qqintl\bin\qq.exe")";7 8System (PATH.C_STR ());//Execution9 TenSystem"Pause"); One}
#include <iostream>